为什么 i=scores.length-1 要减一,是不是因为数组是重零开始的原因
public static void main(String [] args){
int [] scores = {89, -23, 64, 91, 119, 52, 79};
System.out.println("本次考试前三名:");
HelloW hello = new HelloW();
hello.top3(scores);
}
public void top3(int [] scores){
Arrays.sort(scores);
int num=0;
for(int i=scores.length-1;i>=0 && num<3;i--){
if(scores[i]<0 || scores[i]>100){
continue;
}
num++;
System.out.print(scores[i]+",");
}
}