大佬這哪里出錯(cuò)了啊
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("考試成績(jī)的前三名為:"+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;
??? }
}
2018-09-24
你這個(gè)scores1[i]=socres[i]好像就有問(wèn)題吧