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 でも実行できます
結果

実行すると例で試せます。よさそうなら提出しましょう。