import java.util.Scanner;
class RandomNumber
{
public static void main(String[] args)
{
//System.out.println((int)(Math.random()*100)+1);
Scanner scanner = new Scanner(System.in);
int number=(int)(Math.random()*100)+1;
/*while(true){
int number1 = scanner.nextInt();
if (number>number1){
System.out.println("你输入的数字小了"+number1);
} else if(number<number1){
System.out.println("你输入的数字大了"+number1);
} else {
System.out.println("你输入正确了");
break;
}
}
*/
for (; ; )
{
int number1 = scanner.nextInt();
if (number>number1){
System.out.println("你输入的数字小了"+number1);
} else if(number<number1){
System.out.println("你输入的数字大了"+number1);
} else {
System.out.println("你输入正确了");
break;
}
}
}
} |
|