幫忙看下哈
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.ming(scores);
? ? ? ? System.out.println("考試成績的前三名為");
? ? ? ??
? ? ? ??
? ? }
? ??
? ? //定義方法完成成績排序并輸出前三名的功能
? ? public void ming(int[]scores){
? ? ? ? Arrays.sort(scores);
? ? ? ? for(int i=scores.length-1;i>=0;i--){
? ? ? ? ? ? if(scores[i]<0&&scores[i]>100)
? ? ? ? ? ? continue;
? ? ? ? ? ? for(int j=0;j<3;j++){
? ? ? ? ? ? ? ? System.out.println(scores[i]);
? ? ? ? ? ? }
? ? ? ? }
//哪里錯了
2015-12-08
仔細看了一下,首先HelloWorld hello=new HelloWorld()少了括號
其次System.out.println("考試成績的前三名為");要放在hello.ming(scores);前面
然后
記得檢查大括號是不是一一對應
2015-12-08
知道了
2015-12-08
scores[i]<0||scores[i]>100,一個數字不可能既小于0又大于100