import java.util.Scanner;
class DemoRandom {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("请输入一个1到100之间的整数:");
int randomNum = (int) ( Math.random() * 100) +1 ;
while (true) {
int guessNum = sc.nextInt();
if (guessNum > randomNum) {
System.out.println("大了");
}else if (guessNum < randomNum) {
System.out.println("小了");
}else {
System.out.println("中了");
}
}
}
} |
|