[C++] 백준 1032 : 명령 프롬프트

Kim Nahyeong·2022년 1월 16일
0

백준

목록 보기
61/157

#include <iostream>
using namespace std;

string str;
string tmp;
char c;
int main(int argc, char **argv){
    int N;
    scanf("%d",&N);

    cin >> str;
    for(int i=0; i<N-1; i++){
        cin >> tmp;
        for(int j=0; j<tmp.length(); j++){
            c = tmp[j];
            if(c != str[j]){
                str[j] = '?';
            }
        }
    }

    cout << str;

    return 0;
}

오늘의 백준 빼먹지 않으려고 푼 문제. 그냥 단순히 string 입력을 받고 해당 문자열을 순회하면서 해당 문자열이 원 문자열과 다르면 해당 문자를 ?로 치환하면 되는 간단한 문제이다.

0개의 댓글