Java语言编写数字地雷游戏
2021-04-11 05:29
标签:public code tin ring color static rgs exti out Java源代码如下: Java语言编写数字地雷游戏 标签:public code tin ring color static rgs exti out 原文地址:https://www.cnblogs.com/9-King/p/13362614.htmlpublic class Demo01 {
public static void main(String[] args) {
game();
}
static void game(){
int numRandom = new Random().nextInt(100)+1;
Scanner sc = new Scanner(System.in);
System.out.println("请输入你猜的数字:");
while(true) {
int numScanner = sc.nextInt();
if(numRandom>numScanner){
System.out.println("数字小了,重新输入");
}else if(numRandomnumScanner){
System.out.println("数字大了,重新输入");
}else {
System.out.println("恭喜你,猜中了");
break;
}
}
}
}