一次小测验,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;
}
写好了先点「运行」试试示例,没问题再点「提交」。