A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© 0925李超月 中级黑马   /  2015-10-10 21:32  /  299 人查看  /  6 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

import java.util.Scanner;
class Gem {
        public static void main(String[] args) {
                Scanner sc = new Scanner(System.in);
                System.out.println("请输入数字");
                int b = (int)(Math.random() * 100) + 1;       
                int count = 0;
                while (true) {
                        int a = sc.nextInt();
                        if (a > b) {
                                System.out.println("大了");
                        }else if (a < b) {
                                System.out.println("小了");
                        }else if (a == b) {
                                System.out.println("中了");
                                break;
                        }
                        count++;
                       
                }
                System.out.println("你的智商是"+(100 - count));
        }
}

6 个回复

倒序浏览
顶一个
回复 使用道具 举报
我擦被坑了
回复 使用道具 举报
写的不错  满分99
回复 使用道具 举报
呵呵哒,,,,,,
回复 使用道具 举报
哈哈,够迅速,赞一个
回复 使用道具 举报
System.out.println("你的智商是"+(100 - count*10));
这样更爽
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马