switch-case와 배열을 연습해보기 위해 좀 번거롭게 풀어보았다.
배(0) 4개가 모, 등(1) 4개가 모이다. 항상 헷갈린다.
import java.util.Scanner;
public class Bj2490 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int i, j;
int count, temp;
char[] answer = new char[3];
for(i = 0; i < 3; i++)
{
count = 0;
for(j = 0; j < 4; j++)
{
temp = sc.nextInt();
if(temp == 1)//1이 뒤
{
count++;
}
}
switch (count)
{
case 0:
answer[i] = 'D';
break;
case 1:
answer[i] = 'C';
break;
case 2:
answer[i] = 'B';
break;
case 3:
answer[i] = 'A';
break;
default:
answer[i] = 'E';
}
}
for(i = 0; i < answer.length; i++)
{
System.out.println(answer[i]);
}
sc.close();
}
}