import java.util.Scanner;
public class Wukexing {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner input = new Scanner(System.in);
int wo = 0, ta = 0, i = 1;
while (true) {
System.out.println("第" + i + "局输入如下:");
System.out.println("你的输入是:scissor for 0,rock for 1,paper for 2");
int a = input.nextInt();
System.out.println("计算机的输入是:scissor for 0,rock for 1,paper for 2");
System.out.println();
int b = (int) (Math.random() * 3); // 产生一个0~2的随机数并赋给计算
if (a - b == 1 || a - b == -2) {
wo++;
System.out.println("第" + i + "次,你赢了");
} else if (b - a == 1 || b - a == -2) {
ta++;
System.out.println("第" + i + "次,计算机赢了");
} else
System.out.println("第" + i + "次,平局了");
if (wo > 1 || ta > 1)
break;
i++;
}
if (wo > 1)
System.out.println("最终结果是你赢了");
else
System.out.println("最终结果是计算机赢了");
}
}
运行结果如下: