import java.util.Scanner; //导包
class Demo_Math {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in); //创建键盘录入对象
int result = (int)(Math.random() * 100 + 1); //生成随机数
while (true) {
System.out.println("输入一个1——100的一个整数");
int guess = sc.nextInt(); //键盘录入
if (guess > result) {
System.out.println("大啦"); //判断,给出数“大啦”
}else if (guess < result) {
System.out.println("小啦"); //判断,给出数“小啦”
}else {
System.out.println("中奖啦"); //判断,数相等
break;
}
}
}
}
|
|