Kodewick
开始学 →
入门←→0 / 3

最高分

#002入门数组循环约 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 也能运行
结果

写好了先点「运行」试试示例,没问题再点「提交」。