5 Star 52 Fork 0

Gitee Community/码力传递:晒代码赢奖品

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
猜数字 920 Bytes
一键复制 编辑 原始数据 按行查看 历史
梁承宇 提交于 2020-06-05 15:40 +08:00 . 猜数字.java
public static void main(String[] args) throws IOException {
Random a = new Random();
int num = a.nextInt(100);
System.out.println("请输入一个100以内的整数:");
for (int i = 0; i <= 9; i++) {
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
String str = bf.readLine();
int shu = Integer.parseInt(str);
if (shu > num)
System.out.println("输入的数大了,输小点的dao!");
else if (shu < num)
System.out.println("输入的数小了,输大点的!");
else {
System.out.println("恭喜你,猜对了!");
if (i <= 2)
System.out.println("你真是个天才!");
else if (i <= 6)
System.out.println("还将就,你过关了!");
else if (i <= 8)
System.out.println("但是你还……真笨!");
else
System.out.println("你和猪没有两样了!");
break;
}
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/gitee-community/gitee-7th-event-3.git
[email protected]:gitee-community/gitee-7th-event-3.git
gitee-community
gitee-7th-event-3
码力传递:晒代码赢奖品
master

搜索帮助