import java.util.Random;
import java.util.Scanner;
public class RandomTest
{
public static void main(String[] args)
{
Random r=new Random();
int x= r.nextInt(100)+1;
int y=0;
while (true)
{
Scanner sc=new Scanner(System.in);
System.out.println("请玩家输入数字");
y=sc.nextInt();
if (y<x)
{
System.out.println("你输入的数字"+y+"小于正确答案");
}else if (y>x)
{
System.out.println("你输入的数字"+y+"大于正确答案");
}else if (y==x)
{
System.out.println("你猜对了");
}
}
}
}
|
|