求指导,不能输出答案
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | import java.util.Arrays; public class HelloWorld { //完成 main 方法 public static void main(String[] args) { HelloWorld shuchu= new HelloWorld(); int scores[]={ 89 ,- 23 , 64 , 91 , 119 , 52 , 73 }; shuchu.chengji(scores); } //定义方法完成成绩排序并输出前三名的功能 public void chengji( int scores[]) { int count= 0 ; Arrays.sort(scores); for ( int j=scores.length- 1 ;j>= 0 &&count>= 3 ;j--) { if (scores[j]< 0 ||scores[j]> 100 ) continue ; System.out.println(scores[j]); count++; } } } |