import java.util.Scanner;
public class guess{
public static void main(String[] args){
Scanner number1=new Scanner(System.in);
System.out.println("----------猜拳游戏---------");
System.out.println("请出拳(1.剪刀 2.石头 3.布)");
int number=number1.nextInt();
int computer=(int)((Math.random()*3)+1);
String Marks="拳头";//这是做一个标记 number
String Marks1="拳头";//这是做一个标记 computer
switch(number){
case 1:
Marks="剪刀";
break;
case 2:
Marks="石头";
break;
case 3:
Marks="布";
break;
}
switch(computer){
case 1:
Marks1="剪刀";
break;
case 2:
Marks1="石头";
break;
case 3:
Marks="布";
break;
}
if(number==computer){ System.out.println("你出的是"+Marks+",电脑出的是"+Marks1+",平局!");}
else { if(number==1&&computer==2||number==2&&computer==3||number==3&&computer==1){
System.out.println("你出的是"+Marks+",电脑出的是"+Marks1+",你输了!");}
}
else{ System.out.println("你出的是"+Marks+",电脑出的是"+Marks1+",你赢了!"); }
}
}
慕粉13960445854
慕粉17081373449
相关分类