Kodewick
開始學 →
入門←→0 / 70

最高分

#002入門if (scores[i] > best)約 4 分鐘

一次小測驗,n 個人的分數在陣列 scores 裡(至少 1 個)。寫 top_score(scores, n),返回最高的那個分數。

示例
top_score({72, 95, 88}, 3)→95
top_score({60}, 1)→60
函式int top_score(int scores[], int n)
main.c
int top_score(int scores[], int n) {
    int best = scores[0];
    for (int i = 1; i < n; i++) {
        // 在這裡寫:比 best 大,就換成它
    }
    return best;
}
Ctrl + Enter 也能執行
結果

寫好了先點「執行」試試示例,沒問題再點「提交」。