一次小測驗,n 個人的分數在陣列 scores 裡(至少 1 個)。寫 top_score(scores, n),返回最高的那個分數。
top_score({72, 95, 88}, 3)→95top_score({60}, 1)→60int top_score(int scores[], int n)int top_score(int scores[], int n) {
int best = scores[0];
for (int i = 1; i < n; i++) {
// 在這裡寫:比 best 大,就換成它
}
return best;
}
寫好了先點「執行」試試示例,沒問題再點「提交」。