/**
* Random用来生成随机数;
* 获取一个随机的int数字(范围是int所有范围,有正负两种); int num = r.nextInt(这个里面是留空的);
* 获取一个随机的int数字(范围是[0~9),不会包括10); int num = r.nextInt(10);
*/
public class TheRandom {
public static void main(String[] args){
Random sc = new Random();
int num4 = sc.nextInt(10) + 1;//加一就是1~10
Scanner sr = new Scanner(System.in);
System.out.println("猜一下是多少");
while(true){
int n = sr.nextInt();
if (n > num4) {
System.out.println("猜大了");
}else if(n < num4){
System.out.println("猜小了");
}else{
System.out.println("猜对了");
break;
}
}
System.out.println("游戏结束");
}
}