提示運(yùn)行成功,里面卻一個(gè)東西都沒(méi)有,空的。
import java.util.Arrays;?
public class HelloWorld {
?
? ? //完成 main 方法
? ? public static void main(String[] args) {
? ? int scores[]={89,-23,64,91,119,52,73};? ??
? ? HelloWorld hello=new HelloWorld();
? ? hello.Fthree(scores);? ??
? ? ? ??
? ? }
? ??
? ? //定義方法完成成績(jī)排序并輸出前三名的功能
? ? public void Fthree(int scores[]){
? ? ? ? Arrays.sort(scores);
? ? ? ? int count=0;
? ? ? ? for(int i=scores.length-1;i>=0;i--){
? ? ? ? ? ? if(scores[i]<0||scores[i]>100)?
? ? ? ? ? ? continue;
? ? ? ? ? ? count++;
? ? ? ? ? ? if(i>=3) break;
? ? ? ? ? ? System.out.println(scores[i]);
? ? ? ? }
? ? }
}
2018-07-15
第2個(gè)if語(yǔ)句中,應(yīng)該是count>3 ? 不是i>3