qq_慕瓜0112281
2020-01-01 23:40
package wvw;
import java.util.Arrays;
public class HelloWord {
public static void main(String[] args) {
int scores[] = {89,-23,64,91,119,52,73};
HelloWord A = new HelloWord();
System.out.println("成绩前三有:");
A.top3(scores);
/*Arrays.sort(scores);
for(int i = scores.length-1;i >=0;i--) {
System.out.print(scores[i] + " ");*/
}
public void top3(int []scores) {
Arrays.sort(scores);
int mun = 0;
for(int i = scores.length-1;i >=0;i++) {
if(0 <= scores[i] && scores[i] <= 100) {
System.out.print(scores + " ");
}else{
continue;
}
while(mun < 3) {
System.out.print(scores[i]);
mun++;
}
}
}
}
for循环里面的循环变量i应该是递减,你写成i++了
失误哈哈
Java入门第一季(IDEA工具)升级版
1165174 学习 · 17581 问题
相似问题