好像很多bug,請指出
import.java.util.Arrays;
public class HelloWorld {
??? //完成 main 方法
??? public static void main(String[] args) {
??????? HelloWorld hello=new HelloWorld();
??????? int[]?? scores={89,-23,64,91,119,52,73};
??????? hello.sort(scores);
???? }
???
??? //定義方法完成成績排序并輸出前三名的功能
??? Arrays.sort(scores);
??? public int[] sort(int[]? scores)
??? {
??????????? int count=0;
??????????? for(int i=scores.length;i>=0;i--)
??????????? {
?????????????? if(scores[i]<0||scores[i]>100)
?????????????? continue;
?????????????? else
?????????????? count++;
?????????????? while(count>3)
???????????????? break;
??????????? }
??????????? System.out.println("考試成績的前三名為:"? +scores);
??????????? return scores;
??? }
???
???
???
2019-03-15
1.import? java.util.Arrays;
2.定義數組:int [] scores={89,-23,64,91,119,52,73};-定義hello方法:HelloWorld hello=new HelloWorld();之后調用方法hello.showtop3(scores);
3.?Arrays.sort(scores);排序放在showtop3方法里面
4.排序之后的降序排序i值應該從最大值開始i的最大值是scores.length-1??
5.if條件句相當于一個方法? ? ?所以應該用{}來表示方法體里面的內容
2019-03-15
?? Arrays.sort(scores);放在方法里面