import java.util.Scanner;
import java.util.Random;
public class GuessNumber
{
public static void main(String args[])
{
Scanner reader=new Scanner(System.in);
Random random=new Random();
System.out.println("给你一个1至100之间的整数,请猜测这个数");
int realNumber=random.nextInt(100)+1;
int ch;
int yourGuess=0;
System.out.print(realNumber+"输入你的猜测:");
while((yourGuess=reader.nextInt())!=realNumber)
{
if(yourGuess>realNumber)
{
System.out.print("猜大了,再输入你的猜测:");
}
else if(yourGuess<realNumber)
{
System.out.print("猜小了,再输入你的猜测:");
}
}
System.out.println("猜对了!");
}
}
GuessNumber
最新推荐文章于 2022-02-08 09:22:46 发布