import java.util.Scanner;
class Game {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("请输入你心中的数范围1-100之间");
int number = (int)(Math.random()*100) +1;
int sum = 0;
while (true) {
int number2 = sc.nextInt();
if (number2 >number) {
System.out.println("大了");
}else if (number2 < number) {
System.out.println("小了");
}else {
System.out.println("恭喜你答对了");
break;
}
sum++;
if (sum % 5 == 0) {
System.out.println("不要放弃,继续努力");
}
}
}
}
|
|