import java.util.Random;
import java.util.Scanner;
public class RandomTest2 {
public static void main(String[] args) {
System.out.println(“游戏开始*****************************”);
Random ran = new Random();
int a = ran.nextInt(10) + 1; /多次猜数据/
while (1 == 1) {
Scanner sc = new Scanner(System.in);
System.out.println(“请输入你想猜的数字(1~10)”);
int b = sc.nextInt();
if (b > a)
System.out.println(“你猜的数” + b + “大了”);
else if (b < a) System.out.println(“你猜的数” + b + “小了”);
else {
System.out.println(“恭喜你猜对了!!!”);
break;
}
}
System.out.println(“游戏结束*****************************”);
}
}