fork download
  1. import java.io.*;
  2.  
  3. class Main {
  4. public static void main(String[] args) throws IOException {
  5.  
  6. char p1 = br.readLine().charAt(0);
  7. char p2 = br.readLine().charAt(0);
  8.  
  9. switch(p1) {
  10. case 'G':
  11. if (p2 == 'G')
  12. System.out.println("引き分け");
  13. else if (p2 == 'C')
  14. System.out.println("P1の勝ち");
  15. else if (p2 == 'P')
  16. System.out.println("P2の勝ち");
  17. break;
  18. case 'C':
  19. if (p2 == 'G')
  20. System.out.println("P2の勝ち");
  21. else if (p2 == 'C')
  22. System.out.println("引き分け");
  23. else if (p2 == 'P')
  24. System.out.println("P1の勝ち");
  25. break;
  26. case 'P':
  27. if (p2 == 'G')
  28. System.out.println("P1の勝ち");
  29. else if (p2 == 'C')
  30. System.out.println("P2の勝ち");
  31. else if (p2 == 'P')
  32. System.out.println("引き分け");
  33. break;
  34. default:
  35. break;
  36. }
  37. }
  38. }
Success #stdin #stdout 0.02s 245632KB
stdin
P
C
stdout
P2の勝ち