import java.util.Scanner;
class Test2_GuessNum {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
System.out.println("猜数字,范围在1-100");
int guessNum = (int)(Math.random()*100) + 1;
int count = 0;
while (true){
int result = sc.nextInt();
if (result>guessNum){
System.out.println("大了");
count++;
}else if (result<guessNum){
System.out.println("小了");
count++;
}else {
System.out.println("中了");
count++;
break;
}
}
System.out.println(count);
if (count == 1){
System.out.println("你的运气太好了,去买彩票去哇");
}else if (count<10&&count>0){
System.out.println("你太聪明了");
}else {
System.out.println(".......");
}
}
} |
|