哪里出錯(cuò)了 ?
import java.util.Arrays;
public class HelloWorld {
? ??
? ? //完成 main 方法
? ? public static void main(String[] args) {
? ? ? ? int scores[]={89,-23,64,91,119,52,73};
? ? ? ? HelloWorld test=new HelloWorld();
? ? ? ? System.out.println("考試成績(jī)的前三名為:");
? ? ? ? test.scoreMySort(scores);
? ? }
? ? //定義方法完成成績(jī)排序并輸出前三名的功能
? ? public void scoreMySort(int scores[])
? ? {
? ? ? ??
? ? ? ? int count=0; ? //保留有效成績(jī)個(gè)數(shù)
? ? ? ? Arrays.sort(scores); ? // 給數(shù)組排序
? ? ? ? for(int i=scores.length;i>=0;i--) ?// 從最后一位開(kāi)始輸出
? ? ? ? {
? ? ? ? ? ? if(scores[i]<120&&scores[i]>0){
? ? ? ? ? ? System.out.println(scores[i]);}
? ? ? ? ? ? else{
? ? ? ? ? ? continue;}
? ? ? ? ? ? count++;
? ? ? ? ? ? if(count>2)
? ? ? ? ? ? break;
? ? ? ? }
? ? }
}
2016-12-24
for(int i=scores.length-1;i>=0;i--) ?// 從最后一位開(kāi)始輸出
2016-12-24
循環(huán)好像有問(wèn)題
2016-12-23
你還是先把答案看懂來(lái)吧