问答详情
源自:7-1 编程练习

8-1编程练习

答案不对啊  在eclipse上也是错的

提问者:阿Jay 2018-11-25 17:47

个回答

  • Lydia520
    2018-12-11 17:13:00

    import java.util.Arrays;
    public class HelloWorld {
        public static void main(String[] args) {
            int[] scores = {9 , -23 , 64 , 91 , 119 , 52 , 73};
            System.out.println("前三名成绩为:");
            HelloWorld hello = new HelloWorld();
            hello.topthree(scores);
        }
        public void topthree(int[] scores){
            Arrays.sort(scores);
            int count = 0;
            for(int i = scores.length - 1; i >= 0; i--) {
                if(scores[i] > 100 || scores[i] < 0) {
                    continue;
                } //这里要加个括号,不然后面的代码都是这个if语句里的,逻辑上就不正确了
                count++;
                System.out.println(scores[i]);
                if(count >= 3)
                    break;
            }
        }
    } // 这里少了一个括号

    把你上面的代码修改了一下,参考一下吧

  • 阿Jay
    2018-11-26 17:46:34

    https://img.mukewang.com/5bfbc0e000011dd113350775.jpg还是不对。。

  • 慕仰0835374
    2018-11-26 10:17:00

    https://img3.mukewang.com/5bfb57450001aff005340471.jpg

    由于你没有贴出你的代码,我给不好纠错,给你我的答案参考一下

  • zhubiaook
    2018-11-26 01:01:19

    https://img.mukewang.com/5bfad5530001685407060498.jpg

    可以参考一下我的