기타/코딩테스트

2-3. 가위바위보

마늘냄새폴폴 2023. 2. 14. 12:30

package 배열1차원2차원.가위바위보2다시3.my;

import java.util.Scanner;

public class Main {

    /**
     * 잘 풀었습니다. 피드백 할 것은 없습니다.
     */

    public static void main(String[] args) {
        Scanner kb = new Scanner(System.in);
        int num = kb.nextInt();
        int[] A = new int[num], B = new int[num];
        for (int i = 0; i < num; i++) {
            A[i] = kb.nextInt();
        }
        for (int i = 0; i < num; i++) {
            B[i] = kb.nextInt();
        }
        for (int i = 0; i < num; i++) {
            System.out.println(solution(A[i], B[i]));
        }
    }

    private static String solution(int A, int B) {
        String answer = "";

        if (A == B) {
            answer = "D";
        }
        else if (A == 1 && B == 3) {
            answer = "A";
        }
        else if (A == 3 && B == 1) {
            answer = "B";
        }
        else if (A < B) {
            answer = "B";
        }
        else if (A > B) {
            answer = "A";
        }

        return answer;
    }
}

 

완벽하게 풀었다.