小游戏(石头剪刀布)
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("请输入:");
int a = sc.nextInt();
int random=(int)(Math.random()*3)+1;
System.out.println(random);
boolean i = (a == 1 && random == 3)
|| (a == 2 && random == 1)
||(a == 3 && random == 2);
// a=石头, b=剪刀, c=布。
if (a == random){ //平局
System.out.println("平局");
}else if (i) {
System.out.println("你赢了");
} else {
System.out.println("你输了");
}