我自己编写的代码,为什么没有成绩输出呢???

来源:7-1 编程练习

地狱de指挥官

2016-10-23 19:37

import java.util.Arrays;

public class HelloWorld {

    //完成 main 方法

    public static void main(String[] args) {

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

     System.out.println("考试成绩的前三名为:"); 

     HelloWorld hello=new HelloWorld();  

     hello.scs(scores);

    }

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

    public void scs(int[] scores){

        int count=3;

        Arrays.sort(scores);

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

            if (scores[i]>100||scores[i]<0){//不满足条件的成绩跳出

               continue;

               }

            else{

                count--;

                System.out.println(scores[i]);//依次输出前三名成绩

            }   

        }

    }      

}


写回答 关注

1回答

  • 慕粉4265272
    2016-10-23 20:25:44
    已采纳

    i--

    地狱de指挥...

    非常感谢!

    2016-10-23 20:29:29

    共 1 条回复 >

Java入门第一季(IDEA工具)升级版

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

1166387 学习 · 17590 问题

查看课程

相似问题