import java.util.Scanner;
class Game_Test {
public static void main(String[] args) {
System.out.println("请输入1——100内的整数");
Scanner sc = new Scanner(System.in);
int num = (int)(Math.random()*100+1);
Game.guess(num);
}
}
class Game {
Game(){
}
static void guess(int num){
while(true){
Scanner sc = new Scanner(System.in);
int x = sc.nextInt();
if(x<num){
System.out.println("小了");
}
else if(x>num){
System.out.println("大了");
}
else {
System.out.println("中了!");
break;}
}
}
}
有兴趣的可以玩一下 |
|