Dev.baelanche

[백준 1032] 명령 프롬프트 본문

Data Structure & Algorithm/PS - JAVA

[백준 1032] 명령 프롬프트

baelanche 2019. 4. 1. 21:16
반응형

 

배열의 각 인덱스 값이 모두 같을때는 값을 그대로 출력하고 하나라도 다를 경우에 "?" 를 출력하면 된다.

 

 

public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        char arr[][] = new char[n][100];
        
        for(int i=0; i<n; i++) 
            arr[i] = sc.next().toCharArray();
        
        char output[] = arr[0];
        
        for(int i=0; i<output.length; i++) {
            for(int j=0; j<n; j++) {
                if(arr[j][i] == output[i]) continue;
                else output[i] = '?';
            }
        }
        
        for(int i=0; i<output.length; i++)
            System.out.print(output[i]);
}
반응형

'Data Structure & Algorithm > PS - JAVA' 카테고리의 다른 글

[백준 2193] 이친수  (0) 2019.04.02
[백준 15873] 공백 없는 A+B  (4) 2019.04.01
[백준 1026] 보물  (0) 2019.04.01
[백준 1024] 수열의 합  (0) 2019.04.01
[백준 1003] 피보나치 함수  (0) 2019.04.01
Comments