快捷导航

新人求助!!!运行后,一直都是5个数字,不是3个

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.max3(scores);
    }
   
    //定义方法完成成绩排序并输出前三名的功能
   
    public void max3(int[] scores){
        Arrays.sort(scores);
        int nums=0;//定义一个变量,统计有效成绩的前三名的数量
        System.out.println("考试成绩的前三名为:");
        
        for(int i=scores.length-1; nums=0; i--){
            if(scores100){
            continue;
            }
            nums++;
            System.out.println(scores);
            
        }
    }
   
}

免责声明:本内容仅代表回答者见解不代表本站观点,请谨慎对待。

版权声明:作者保留权利,不代表本站立场。

回复

使用道具 举报

参与会员1

nums=0 你或许是想写nums=0
回复

使用道具 举报

可能感兴趣的问答

发新帖
  • 微信访问
  • 手机APP