锤剪布
锤子剪刀布 (20)
http://www.nowcoder.com/questionTerminal/79db907555c24b15a9c73f7f7d0e2471
import java.util.Scanner; public class test { public static void main(String[] args){ Scanner input =new Scanner(System.in); int num=input.nextInt(); String[][] com=new String[num][2]; for(int i=0;i<num;i++){ com[i][0]=input.next(); com[i][1]=input.next(); } int win=0; int bal=0; int lose=0; int winC1=0; int winC2=0; int winJ1=0; int winJ2=0; int winB1=0; int winB2=0; for(int i=0;i<num;i++){ if(com[i][0].equals("C")){ if(com[i][1].equals("J")){ win++; winC1++; }else if(com[i][1].equals("B")){ lose++; winB2++; }else{ bal++; } } if(com[i][0].equals("J")){ if(com[i][1].equals("B")){ win++; winJ1++; }else if(com[i][1].equals("C")){ lose++; winC2++; }else{ bal++; } } if(com[i][0].equals("B")){ if(com[i][1].equals("C")){ win++; winB1++; }else if(com[i][1].equals("J")){ lose++; winJ2++; }else{ bal++; } } } System.out.println(win+" "+bal+" "+lose); System.out.println(lose+" "+bal+" "+win); if(winC1>winB1){ if(winC1>=winJ1) System.out.print("C "); else System.out.print("J "); }else {//winC1<=winB1 if(winB1>=winJ1) System.out.print("B "); else System.out.print("J "); } if(winC2>winB2){ if(winC2>=winJ2) System.out.print("C"); else System.out.print("J"); }else {//winC1<=winB1 if(winB2>=winJ2) System.out.print("B"); else System.out.print("J"); } } }