哪里出錯?。?/h1>
import java.util.Arrays;
public class HelloWorld {
???
??? //完成 main 方法
??? public static void main(String[] args) {
??????? int[] scores={89,-23,64,91,119,52,73};
??????? int[] score=cal(scores);
??????? dips(score);
???????
???????
??? }
???
??? private static void dips(int[] score) {
??? ?System.out.println("考試成績的前三名是:");
??? ?int num=0;
??for(int i=score.length-1;i>0;i--)
???{
????if(score[i]>100||score[i]<0)
?????continue;
????System.out.println(score[i]);// TODO Auto-generated method stub
?????num++;
????if(num>2)
?????break;
???}
?}
?private static int[] cal(int[] scores) {
??? ?Arrays.sort(scores);
??return scores;
?}
???
???
???
???
import java.util.Arrays;
public class HelloWorld {
???
??? //完成 main 方法
??? public static void main(String[] args) {
??????? int[] scores={89,-23,64,91,119,52,73};
??????? int[] score=cal(scores);
??????? dips(score);
???????
???????
??? }
???
??? private static void dips(int[] score) {
??? ?System.out.println("考試成績的前三名是:");
??? ?int num=0;
??for(int i=score.length-1;i>0;i--)
???{
????if(score[i]>100||score[i]<0)
?????continue;
????System.out.println(score[i]);// TODO Auto-generated method stub
?????num++;
????if(num>2)
?????break;
???}
?}
?private static int[] cal(int[] scores) {
??? ?Arrays.sort(scores);
??return scores;
?}
???
???
???
???
2019-03-28
少了個大括號,在最后面加一個大括號就好
推薦用eclipse,代碼復制進去直接就提示錯誤了
2019-04-05
除了樓上說的在最后加大括號,此題情況下雖然不影響執(zhí)行結果但為了嚴謹仍建議將for循環(huán)的表達式2改成i>=0;
2019-04-04
在最后面加多個大括號 } ,就行了,少了個大括號。
2019-03-28
num>2改成num>3,最后一個方法名是不是有問題?
2019-03-28
?for(int i=score.length-1;i>0;i--)
的score 改成scores試試