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

编程序,急用

编程序,急用

C++
天堂的蒲公英 2017-04-01 20:45:09
求哪位大佬帮忙编一个程序,不要太小,要有注释,急用
查看完整描述

3 回答

已采纳
?
ziom

TA贡献948条经验 获得超1109个赞

import java.util.Arrays;

public class HelloWorld {
    
    //完成 main 方法
    public static void main(String[] args) {
        HelloWorld hw = new HelloWorld();
        int[] scores = {89, -23, 64, 91, 119, 52, 73};
        hw.printTop3(scores);    
        
    }
    
    //定义方法完成成绩排序并输出前三名的功能
    public void printTop3(int[] scores) {
        Arrays.sort(scores);
        int count = 0;
        System.out.println("考试成绩的前三名为:");
        // 注意:循环变量变化应为:i--
        for (int i = scores.length-1; i >= 0; i--) {
            if (scores[i] >= 0 && scores[i] <= 100) {
                count++;
                if (count > 3) break;
                System.out.println(scores[i]);
            }
        }
    }
    
}

求采纳

查看完整回答
反对 回复 2017-04-02
?
ziom

TA贡献948条经验 获得超1109个赞

需求呢

查看完整回答
1 反对 回复 2017-04-01
  • 3 回答
  • 0 关注
  • 1372 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信