找不到問題,求大神支援
import java.util.Arrays;
public class HelloWorld {
? ??
? ? //完成 main 方法
? ? public static void main(String[] args) {
? ? ? ? int [] h={90,98,89,78,68,0};
? ? ? ? HelloWorld hello=new HelloWorld();
? ? ? ? int []g=hello.getScores(h);
? ? ? ? System.out.println("考試成績的前三名為:");
? ? ? ? for(int d:g){
? ? ? ? ? ? System.out.println(d);
? ? ? ? }
? ? ? ??
? ? }
? ??
? ? //定義方法完成成績排序并輸出前三名的功能
? ? public int[] getScores(int[]a){
? ? ? ? int []b=Arrays.sort(a);
? ? ? ? int []c=new int[3];
? ? ? ? for(int i=0;i<c.length;i++){
? ? ? ? ? ? if(b[i]<100&&b[i]>0)
? ? ? ? ? ? c[i]=b[i];
? ? ? ? ? ? else
? ? ? ? ? ? c[i]=0;
? ? ? ? }
? ? ? ?return c;?
? ? }
}
2016-07-12
你根本沒按提示做按。。。
這是我的方法,希望采納。
2016-07-07
這是我寫的答案,可能有點(diǎn)小麻煩吧,你可以看一下。如果不是因?yàn)椴恢涝趺磳?,而是因?yàn)椴恢滥愕臑槭裁磿?huì)出現(xiàn)問題的話,可以私聊我,我?guī)湍憬忉屢幌隆?/p>