結(jié)果正確,這樣可以嗎?
public class practice {
public static void main(String[] args) {
System.out.println("考試成績的前三名為:");
int[] num = {89,-23,64,91,119,52,73};
Arrays.sort(num);
int j=0;
? ? ? ? for(int i=num.length-1;i>=0;i--){
? ? ? ? ? ? if (num[i]<0||num[i]>100)
? ? ? ? ? ? {
? ? ? ? ? ? continue;
? ? ? ? ? ? }
? ? ? ? ? ? j++;
? ? ? ? ? ? if (j>3) {
break;
}
? ? ? ? ? ? System.out.println(num[i]);
? ? ? ? }
}
}
2017-05-07
這樣是沒問題的。但是不建議這樣的把所有操作全寫在main函數(shù)中,當內(nèi)容多的時候不容易整理。建議把操作寫進方法中
2017-05-07
這樣完全可以