import java.util.Scanner;
class GuessNumber {
public static void main(String[] args) {
int a = (int)((Math.random() * 100) + 1);
while(true) {
Scanner sc = new Scanner(System.in);
System.out.println("请输入要猜的数字,范围是0-100之间");
int b = sc.nextInt();
if(b < a) {
System.out.println("您输入的数:" + b + "小了");
}
else if(b > a) {
System.out.println("您输入的数:" + b + "大了");
}
else {
System.out.println("恭喜您,您答对了");
break;
}
}
}
}
|
|