java----猜拳
package learning;
import java.util.*;
public class Guesstest {
public static void main(String [] args) {
int i=0;
for(;i<10;i++) {
System.out.println("-----猜拳游戏-----");
System.out.println("请出拳(-1,石头 0.剪刀 1布)");
Scanner in = new Scanner(System.in);
int person = in.nextInt();
int computer = (int)(Math.random()*3)-1;
String Marks="拳头";
String Marks2="拳头";
switch(person){
case -1:
Marks = "石头";
break;
case 0:
Marks = "剪刀";
break;
case 1:
Marks = "布";
break;
}
switch(computer){
case -1:
Marks2 = "石头";
break;
case 0:
Marks2 = "剪刀";
break;
case 1:
Marks2 = "布";
break;
}
if(person ==computer) {
System.out.println("平局"+"你出的是"+Marks+",电脑出的是"+Marks2);
}else if(person==-1&&computer==1||person==0&&computer==-1||person==1&&computer==0){
System.out.println("你输了"+"你出的是"+Marks+",电脑出的是"+Marks2);
}else {
System.out.println("你赢了"+"你出的是"+Marks+",电脑出的是"+Marks2);
i = 10;
}
}
}
}