import java.util.Scanner;
class Demo_Math {
public static void main(String[] args) {
Scanner sc =new Scanner(System.in);
System.out.println("下面进行猜数,范围为1—100,请输入一个整数");
int guessNum = (int)(Math.random()*100)+1;
while (true){
int result = sc.nextInt();
if (result > guessNum){
System.out.println("大了");
}else if (result<guessNum){
System.out.println("小了");
}else {
System.out.println("恭喜你猜中了");
break;
}
}
}
}
|
|