public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
//在0-100内 生成的结果数字
int result = new Random().nextInt(100);
//猜对的次数
int count = 1;
boolean flag = true;
do {
System.out.print("请输入数字:");
int x = scanner.nextInt(); //此处不捕抓异常,全靠自觉
if(x > result){
System.out.println("猜大了");
}else if(x < result){
System.out.println("猜小了");
}else if(x == result) {
System.out.println("恭喜,第" + count + "次猜对了");
flag = false;
}
count++;
} while (flag);
}
for循环里面应该都是分号吧