阿Jay
2018-11-25 17:47
答案不对啊 在eclipse上也是错的
import java.util.Arrays;
public class HelloWorld {
public static void main(String[] args) {
int[] scores = {9 , -23 , 64 , 91 , 119 , 52 , 73};
System.out.println("前三名成绩为:");
HelloWorld hello = new HelloWorld();
hello.topthree(scores);
}
public void topthree(int[] scores){
Arrays.sort(scores);
int count = 0;
for(int i = scores.length - 1; i >= 0; i--) {
if(scores[i] > 100 || scores[i] < 0) {
continue;
} //这里要加个括号,不然后面的代码都是这个if语句里的,逻辑上就不正确了
count++;
System.out.println(scores[i]);
if(count >= 3)
break;
}
}
} // 这里少了一个括号把你上面的代码修改了一下,参考一下吧
还是不对。。

由于你没有贴出你的代码,我给不好纠错,给你我的答案参考一下

可以参考一下我的
Java入门第一季(IDEA工具)
1168083 学习 · 18754 问题
相似问题