/*
产生一个1-100的随机数
*/
import java.util.Scanner;
import java.util.Random;
class Game
{
public static void main(String[] args)
{
Random r = new Random();
int num = r.nextInt(100)+1;
System.out.println("请输入一个1-100数字");
Scanner sc = new Scanner(System.in);
while (true)
{
int number = sc.nextInt();
if (number==num)
{
System.out.println("输入正确");
break;
}
else if (number>num)
{
System.out.println("输入的数据大了");
}
else
{
System.out.println("你输入的数据小了");
}
}
}
} |
|