728x90

 

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	    public static void main(String[] args) throws IOException{
	    	
	    	//입력
	    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	    	int n = Integer.parseInt(br.readLine());
	    	String firstName = br.readLine();
	    	String compareName [] = new String [n];
	    	Character result [] = new Character [firstName.length()];
	    	
	    	for(int i = 0; i < n-1; i++) {
	    		compareName[i] = br.readLine();
	    	}
	    	
	    	//값 구하기
	    	if(n == 1) {
	    		for(int i = 0; i < firstName.length(); i++) {
	    			result[i] = firstName.charAt(i);
	    		}
	    	}else {
		    	for(int i = 0; i < n-1; i++) {
		    		for(int j = 0; j < firstName.length(); j++) {
		    			if(i == 0) {
					    	if(firstName.charAt(j) == compareName[i].charAt(j)) {
					    		result[j] = firstName.charAt(j);
					    	}else {
					    		result[j] = '?';			    		
					    	}
		    			}else {
		    				if(result[j] == compareName[i].charAt(j)) {
					    		result[j] = firstName.charAt(j);
					    	}else {
					    		result[j] = '?';			    		
					    	}
		    			}
		    		}
		    	}
	    	}
	    	
	    	//출력
	    	for(int i = 0; i < firstName.length() ; i++) {
	    		System.out.print(result[i]);
	    	}
	    }
}

* 체크할점

- charAt을 .equals 로 비교하려면 Character.toString(a.charAt(1)); 식으로 toString 처리해야함.

char 자체는 == ' ' 으로 비교하면 됨 / " "은 스트링, ' '은 char 기억하기~!

cf) toCharArray(); : 문자열을 char 배열로 만들어준다.

- 첫번째 입력받은 값을 비교대상으로 쓰는 것은 생각하지 못했음

728x90

+ Recent posts