数字炸弹游戏第二版
作者:互联网
import java.util.Random;
import java.util.Scanner;
public class GAME3 {
public static void main(String[] args) {
Random A = new Random();
int a = A.nextInt(101);//随机一个数
Scanner B = new Scanner(System.in);
System.out.println("输入一个零到一百的数字开始游戏")
int c = 100;
int d=0;
while (true) {
int b = B.nextInt();//输入数据
if (a > b) {
System.out.println("小了");
System.out.println("请输入" + b + "到" + c + "的数");
d=b;
}
else if (a < b){
System.out.println("大了");
System.out.println("请输入" + d + "到" + b + "的数");
c=b;
}else {
System.out.println("恭喜你!猜对了!");
System.out.println("==========================");
break;
}
}
}
}
标签:游戏,int,Random,System,Scanner,炸弹,数字,println,out 来源: https://blog.csdn.net/weixin_44548893/article/details/118681103