import java.util.Random;
import java.util.Scanner;
/**
* 功能:猜数游戏
* 作者:Neroiie
* 日期:
*/
public class Task09 {
public static void main(String[] args) {
//声明部分
int x,target;
Scanner sc = new Scanner(System.in);
//产生猜测目标
Random random = new Random();
target = random.nextInt(100);
//输入猜测数
System.out.print("输入一个[1,100]的整数:");
x= sc.nextInt();
while (x != target){
//判断大小
if(x>target){
System.out.println("猜高了!");
}else {
System.out.println("猜低了!");
}
//继续输入
System.out.print("输入一个[1,100]的整数:");
x= sc.nextInt();
}
System.out.println("恭喜你猜对了,游戏结束!!!");
}
}
```![在这里插入图片描述](https://img-blog.csdnimg.cn/89457ad1a59144fbba6b76b854833df3.png#pic_center)
10-16
2万+
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
09-11
1143
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)