gistfile1.txt int a=0;Scanner s=new Scanner(System.in);System.out.println("--------------猜拳游戏---------------");System.out.println(" ");System.out.println(" ");while(a=0) {System.out.println("请出拳:1、石头 2、剪刀 3、布")
int a=0; Scanner s=new Scanner(System.in); System.out.println("--------------猜拳游戏---------------"); System.out.println(" "); System.out.println(" "); while(a>=0) { System.out.println("请出拳:1、石头 2、剪刀 3、布"); int x=s.nextInt(); Random on=new Random(); int y=on.nextInt(3)+1; if(x>=4||x==0) { System.out.println("亲,请正确输入"); } else { if(x==y) { if(x==1) { a++; System.out.println("石头------电脑:石头 PK:很幸运打平手"); System.out.println(" "); System.out.println(" "); } else if(x==2) { a++; System.out.println("剪刀------电脑:剪刀 PK:很幸运打平手"); System.out.println(" "); System.out.println(" "); }else { a++; System.out.println("布------电脑:布 PK:很幸运打平手"); System.out.println(" "); System.out.println(" "); } } else if(x==1&&y==2||x==2&&y==3||x==3&&y==1){ if(x==1&&y==2) { a++; System.out.println("石头------电脑:剪刀 PK:恭喜您,赢了!"); System.out.println(" "); System.out.println(" "); }else if(x==2&&y==3) { a++; System.out.println("剪刀------电脑:布 PK:恭喜您,赢了!"); System.out.println(" "); System.out.println(" "); }else { a++; System.out.println("布------电脑:石头 PK:恭喜您,赢了!"); System.out.println(" "); System.out.println(" "); } } else{ if(x==1&&y==3) { a++; System.out.println("石头------电脑:布 PK:很遗憾,输了!"); System.out.println(" "); System.out.println(" "); }else if(x==2&&y==1) { a++; System.out.println("剪刀------电脑:石头 PK:很遗憾,输了!"); System.out.println(" "); System.out.println(" "); }else { a++; System.out.println("布------电脑:剪刀 PK:很遗憾,输了!"); System.out.println(" "); System.out.println(" "); } } } }