猿问

求大神查错

package one;


import java.util.Arrays;


public class one {
   
    //完成 main 方法
    public static void main(String[] args) {
       
       one hello=new one();
      
        int[] scores={89 , -23 , 64 , 91 , 119 , 52 , 73};
       
        int[] three=hello.change(scores);                                                 //wrong
        
        System.out.println(three);
       
    }
   
    //定义方法完成成绩排序并输出前三名的功能
    public  int change(int[] scores){
       
        Arrays.sort(scores);
       
        int[] one=new int[3];
       
        for(int i = 0 ; i < 3 ; i++){
           
            if(scores[i] > 0 && scores[i] < 100){
           
            int m=0;
           
               one[m]=scores[i];
               
                m++;
            }
       
        return one;                                                                                 //wrong
       
        }
    }
       
}


慕少4018567
浏览 1191回答 1
1回答

慕莱坞9220042

你好,package one; import java.util.Arrays; public class one {          //完成 main 方法     public static void main(String[] args) {                 one hello=new one();                 int[] scores={89 , -23 , 64 , 91 , 119 , 52 , 73};                  int[] three=hello.change(scores);                                                 //wrong         for (int i = 0; i < three.length; i++) {          System.out.println(three[i]+","); }         System.out.println(three);             }          //定义方法完成成绩排序并输出前三名的功能     public  int[] change(int[] scores){                  Arrays.sort(scores);                  int[] one=new int[3];                  for(int i = 0 ; i < 3 ; i++){                          if(scores[i] > 0 && scores[i] < 100){                          int m=0;                             one[m]=scores[i];                                  m++;             }                  }         return one;                                                                        //wrong     }          }试下这个,可以正常运行,具体输出好像有问题,自己查下代码看下哪里不对;望楼主采纳!
随时随地看视频慕课网APP

相关分类

Java
我要回答