본문 바로가기
알고리즘/SWEA

[SWEA] 9317. 석찬이의 받아쓰기

by hyerann 2020. 2. 20.

https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AW-hOY5KeEIDFAVg&categoryId=AW-hOY5KeEIDFAVg&categoryType=CODE

 

SW Expert Academy

SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!

swexpertacademy.com

#include <iostream>

using namespace std;

int N;
string str1, str2;

int getResult() {
    int result = 0;
    
    for(int i=0; i<N; i++) {
        if(str1[i] == str2[i]) result++;
    }
    
    return result;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    
    int tc; cin >> tc;
    
    for(int i=1; i<=tc; i++) {
        cin >> N >> str1 >> str2;
        cout << '#' << i << ' ' << getResult() << '\n';
    }
    
    return 0;
}

댓글