public class Main {
public static void main(String[] args) {
System.out.println("please choice:");
System.out.println(" 1: Rock");
System.out.println(" 2: Scissors");
System.out.println(" 3: Paper");
// 用户输入:
Scanner scanner = new Scanner(System.in);
int choice = scanner.nextInt();
// 计算机随机数 1, 2, 3:
int random = 1 + (int) Math.random() * 3;
System.out.printf("random is:%d",random);
switch (choice-random) {
// TODO:
case 0:
System.out.println("平局");
break;
case 1:
System.out.println("你输了!");
case 2:
System.out.println("你赢了!");
case -1:
case -2:
default:
}
Sign in to make a reply
一只努力的小南瓜
public class Main {
public static void main(String[] args) {
System.out.println("please choice:");
System.out.println(" 1: Rock");
System.out.println(" 2: Scissors");
System.out.println(" 3: Paper");
// 用户输入:
Scanner scanner = new Scanner(System.in);
int choice = scanner.nextInt();
// 计算机随机数 1, 2, 3:
int random = 1 + (int) Math.random() * 3;
System.out.printf("random is:%d",random);
switch (choice-random) {
// TODO:
case 0:
System.out.println("平局");
break;
case 1:
System.out.println("你输了!");
case 2:
System.out.println("你赢了!");
case -1:
System.out.println("你赢了!");
break;
case -2:
System.out.println("你输了!");
break;
default:
break;
}
}
}