這樣為啥是失敗的?哪里出錯了額?
public class Test {
public static void main(String[] args) {
// TODO Auto-generated method stub
? ? ? ? Test t=new Test();
? ? ? ? int[] scores={89,-23,64,91,119,52,73};
? ? ? ? t.rank(scores);
? ? ? ??
}
?
public void rank(int[] score){
? ? ? ? int[] score2= {};
? ? ? ? Arrays.sort(score);
? ? ? ? for(int i=0;i < score.length;i++){
? ? ? ? ? ? if(score[i]>100 || score[i]<0){
? ? ? ? ? ? ? ? continue;
? ? ? ? ? ? }
? ? ? ? ? ? score2[i]=score[i];
? ? ? ? }
? ? ? ? for(int j=score2.length-1;j<score2.length-4;j--){
? ? ? ? System.out.println(score2[j]);
? ? ? ? }}}
2019-01-29
package?imooc.Test; import?java.util.Arrays; public?class?Test?{ public?static?void?main(String[]?args)?{ //?TODO?Auto-generated?method?stub ????????Test?t=new?Test(); ????????int[]?scores={89,-23,64,91,119,52,73}; ????????t.rank(scores); ???????? } ? public?void?rank(int[]?score){ ????????int[]?score2=new?int[score.length]; ????????Arrays.sort(score); ????????for(int?i=0;i?<?score.length;i++){ ????????????if(score[i]>100?||?score[i]<0){ ????????????????continue; ????????????} ????????????score2[i]=score[i]; ????????} ????????for(int?j=score2.length-1;j<score2.length-4;j--){ ????????System.out.println(score2[j]); ????????}}}吶,現在可以運行了,不知道什么功能,所以我就改成了能運行的樣子