为了账号安全,请及时绑定邮箱和手机立即绑定

哪里有问题啊,大神们?

import java.util.Arrays;

public class HelloWorld {

    

    //完成 main 方法

    public static void main(String[] args) {

        

        int[] scores = { 89,-23,64,91,119,52,73 };

        HelloWorld hello = new HelloWorld();

        hello.mark(scores);

            }

    public void mark(int[] scores) {

        Arrays.sort(scores);

              int num = 0;

        for (int i=scores.length-1;i>=0;i++){

           if (scores[i]<=0||scores[i]>100) {

               continue;

           }

            num++;

            if ( num>3 ){

                break;

            }

            System.out.println(scores[i]);

        }

    }

    //定义方法完成成绩排序并输出前三名的功能

    

    


正在回答

2 回答

for语句那行i++改成i--;main方法里没有打印“考试成绩的前三名为:”

0 回复 有任何疑惑可以回复我~
#1

慕粉3434242 提问者

非常感谢!
2016-06-01 回复 有任何疑惑可以回复我~

import java.util.Arrays;


public class HelloWorld {

    

    //完成 main 方法

    public static void main(String[] args) {

        int[] scores = {89 , -23 , 64 , 91 , 119 , 52 , 73};   

        HelloWorld hello = new HelloWorld();

        hello.fun(scores);  

    }

    

    //定义方法完成成绩排序并输出前三名的功能

    

    public void fun(int[] num)

    {

        int count = 3;

        for(int i = num.length-1 ;i>=0&&count >0;i--)

        {

            Arrays.sort(num);

            if (num[i] > 0 && num[i] < 100)

            {

                System.out.println(num[i]);

                count --;

            }

        }

    }


0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消
Java入门第一季(IDEA工具)升级版
  • 参与学习       1167832    人
  • 解答问题       18749    个

0基础萌新入门第一课,从Java环境搭建、工具使用、基础语法开始

进入课程

哪里有问题啊,大神们?

我要回答 关注问题
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号