import java.util.*;
class numGame2{
public static void main(String[] args) {
int guessNumber=(int)(Math.random() * 100)+1;
Scanner Sc =new Scanner(System.in);
System.out.print("亲爱哒,请输入一个辛运数字吧:");
int max=100;
int min=0;
while (true) {
int result = Sc.nextInt();
if (result > guessNumber) {
max = result;
System.out.println("不对哦,再接再厉哦.请在"+max+"和"+min+"之间重新输入您的幸运数字吧:");
}else if (result <guessNumber) {
min = result;
System.out.print("不对哦,加油哦,请在"+min+"和"+max+"之间重新输入您的幸运数字吧:");
}else {System.out.println("终于找到你,还好我没放弃!");}
}
}
}
|
|