๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
Algorithm ๐Ÿง‘๐Ÿป‍๐Ÿ’ป/๋ฐฑ์ค€(BOJ)

[๋ฐฑ์ค€,c++] 1032๋ฒˆ - ๋ช…๋ น ํ”„๋กฌํ”„ํŠธ

by ์•ˆ์ฃผํ˜• 2021. 10. 16.
 

1032๋ฒˆ: ๋ช…๋ น ํ”„๋กฌํ”„ํŠธ

์ฒซ์งธ ์ค„์— ํŒŒ์ผ ์ด๋ฆ„์˜ ๊ฐœ์ˆ˜ N์ด ์ฃผ์–ด์ง„๋‹ค. ๋‘˜์งธ ์ค„๋ถ€ํ„ฐ N๊ฐœ์˜ ์ค„์—๋Š” ํŒŒ์ผ ์ด๋ฆ„์ด ์ฃผ์–ด์ง„๋‹ค. N์€ 50๋ณด๋‹ค ์ž‘๊ฑฐ๋‚˜ ๊ฐ™์€ ์ž์—ฐ์ˆ˜์ด๊ณ  ํŒŒ์ผ ์ด๋ฆ„์˜ ๊ธธ์ด๋Š” ๋ชจ๋‘ ๊ฐ™๊ณ  ๊ธธ์ด๋Š” ์ตœ๋Œ€ 50์ด๋‹ค. ํŒŒ์ผ์ด๋ฆ„์€

www.acmicpc.net

//  Copyright © 2021 ์•ˆ์ฃผํ˜•. All rights reserved.
//  
//  https://www.acmicpc.net/problem/1032
//  BOJ1032 ๋ช…๋ น ํ”„๋กฌํ”„ํŠธ

#include <iostream>
#include <algorithm>
using namespace std;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int N; cin >> N;
    string check; cin >> check;
    string temp = check;
    for (int i = 0; i < N-1; i++) {
        string s; cin >> s;
        for (int k = 0; k < check.length(); k++) {
            if (check[k] != s[k]) {
                temp[k] = '?';
            }
        }
    }
    cout << temp;
}

๋Œ“๊ธ€