package com;
import java.util.Arrays;
public class Demon6 {
public static void main(String[] args) {
Demon6 hello=new Demon6();
int[] scores= {89,-23,64,91,119,52,73};
int[] scores1=hello.sort(scores);
System.out.println("考试成绩的前三名为:"+Arrays.toString(scores1));
}
public int[] sort(int[] scores) {
Arrays.sort(scores);
int[] scores1=new int[3];
int num=0;
for(int i=scores.length-1;i>=0&&num<3;i--) {
if(scores[i]<0||scores[i]>100) {
continue;
}
num++;
scores1[i]=scores[i];
}
return scores1;
}
}
你这个scores1[i]=socres[i]好像就有问题吧