1 条题解

  • 0
    @ 2023-9-23 12:27:07
    import java.util.Scanner;
    
    public class Main {
        public static void main(String[] args) {
            final Scanner scanner = new Scanner(System.in);
            final int gamePlayed = scanner.nextInt();
            final StringBuilder results = new StringBuilder();
            for (int i = 0; i < gamePlayed; i++) {
                if (results.length() > 0) results.append("\n");
                final String resultA = scanner.next(), resultB = scanner.next();
                if (resultA.equals(resultB)) {
                    results.append("Tie");
                    continue;
                }
                switch (resultA) {
                    case "Rock": {
                        results.append(resultB.equals("Scissors") ? "Player1" : "Player2");
                        continue;
                    }
                    case "Paper": {
                        results.append(resultB.equals("Rock") ? "Player1" : "Player2");
                        continue;
                    }
                    default: {
                        results.append(resultB.equals("Paper") ? "Player1" : "Player2");
                    }
                }
            }
            System.out.println(results);
        }
    }
    
    • 1

    信息

    ID
    133
    时间
    1000ms
    内存
    128MiB
    难度
    6
    标签
    (无)
    递交数
    723
    已通过
    222
    上传者