文字太多發不上來,我發圖檔吧
這是運作結果,你核對下;
先上部分代碼public static void main(String[] args) {
String[] Names = {"張三豐", "郭靖", "喬峰", "張無忌", "楊過"};
String[] cNames = {"Java", "C++", "Oracle", "Android"};
int[][] score = {
{87, 76, 63, 98},
{67, 79, 83, 75},
{90, 76, 65, 60},
{84, 88, 63, 79},
{72, 66, 58, 77},
};
// 周遊科目
for (int i = 0; i
// 科目名
String subject = cNames[i];
// 儲存一個科目的分數
int[] subScores = new int[Names.length];
String[] sortName = new String[Names.length];
for (int j = 0; j
sortName[j] = Names[j];
subScores[j] = score[j][i];
}
sortTwo(subScores, sortName);
// 輸出成績和姓名
System.out.println(subject + " 的成績排名:");
for (int x = 0; x
System.out.print(subScores[x] + ",\t\t");
}
System.out.println("\n----");
for (int x = 0; x
System.out.print(sortName[x] + ",\t");
}
System.out.println("\n");
}
}