BackJoon Algorithm 2490 윷놀이

업데이트:
최대 1 분 소요

BackJoon Algorithm - Java

alt

문제

alt

풀이

  • if문 활용
    import java.util.Scanner;
public class Back_2490 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        // given
        int arr[]=new int[4];
        // when
        for(int j=0;j<3;j++) {
            int count=0;
            for (int i = 0; i < arr.length; i++) {
                arr[i] = sc.nextInt();
                if (arr[i] == 1) {
                    count++;
                }
            }
            //  then
            if (count == 4) {
                System.out.println("E");
            } else if (count == 3) {
                System.out.println("A");
            } else if (count == 2) {
                System.out.println("B");
            } else if (count == 1) {
                System.out.println("C");
            } else if(count==0){
                System.out.println("D");
            }

        }
    }
}

댓글남기기