import java.util.Scanner;
class GuessNumber
{
public static void main(String[] args)
{ int number=(int)(10*Math.random())+1;
while (true)
{
Scanner s=new Scanner(System.in);
System.out.println("请 你输入你要猜的数字:");
int guess=s.nextInt();
if(guess>number)
{
System.out.println("你猜的数"+guess+"大了");
}
else if(guess<number)
{
System.out.println("你猜的数"+guess+"小了");
}
else
{
System.out.println("恭喜你猜对了 "+guess);
return;
}
}
}
}
|
|