import java.util.Random;标签:Scanner,System,随机,println,100,out,数字 From: https://www.cnblogs.com/nulicheng/p/17844049.html
import java.util.Scanner;
public class HelloWorld {
public static void main(String[] args) {
//题目生成0-100的随机数字。
Random random=new Random();
int i =random.nextInt(101); //创建0-100的随机数字。
Scanner scanner =new Scanner(System.in); //创建Scanner
while (true){
System.out.println("请输入数字");
int yonghu=scanner.nextInt(); //用户输入
if (yonghu>i){
System.out.println("您输入的数字过大");
}else if (yonghu<i){
System.out.println("您输入的数字过小");
}else{
System.out.println("恭喜您输入正确,游戏结束");
break;
}
}
}
}