package com.zhang.random;
import java.util.Random;
import java.util.Scanner;
public class RandomTest2 {
public static void main(String[] args) {
//随机生成一个1~100之间的数,提示用户猜测,猜大提示猜大,猜小提示小了,直到用户猜中
Random r = new Random();
int boom = r.nextInt(100-1) + 1;
System.out.println("请输入1~100之间你猜的数字~~~~~~");
Scanner s = new Scanner(System.in);
int num = s.nextInt();
while (num != boom) {
if(num < boom){
System.out.println("请猜小一点的数~~~");
num = s.nextInt();
}else{
System.out.println("请猜大一点的数~~~");
num = s.nextInt();
}
System.out.println("猜对啦!!!");
}
}
}