import java.util.Scanner;
class Test4 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int num = (int)(Math.random() * 100)+ 1;
System.out.println("请输入一个数:");
//int x = sc.nextInt();
/*if (x == num) {
System.out.println("你输对了");
}else {
System.out.println("你猜错了");
}*/
for (int i =0; ; i++) {
int x = sc.nextInt();
if (x > num) {
System.out.println("你猜大了");
}else if (x < num) {
System.out.println("你猜小了");
}else {
System.out.println("终于对了");
break;
}
}
}
}
|
|