백준 1032번)명령 프롬프트

하우르·2021년 3월 25일
0
package 신규아이디추천;

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

public class Main {


	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		int test_case_num=Integer.parseInt(reader.readLine());
		ArrayList<String> file_list = new ArrayList<String>();
		String answer = "";
		for(int i=0; i<test_case_num;i++)
			file_list.add(reader.readLine());

		String temp_alp1=null;
		for(int i=0; i<file_list.get(0).length();i++)
		{
			for(int j=0; j<file_list.size();j++)
			{
				String temp_alp2 = file_list.get(j).charAt(i)+"";

				if(j==0)
					temp_alp1 = temp_alp2;
				else if(temp_alp1.equals(temp_alp2))
					temp_alp1 = temp_alp2;
				else if(!temp_alp1.equals(temp_alp2))
				{
					temp_alp1="no";
					break;
				}
			}
			if(temp_alp1.equals("no"))
				answer+="?";
			else
				answer+=temp_alp1;

		}

		System.out.println(answer);
	}
}
profile
주니어 개발자

0개의 댓글