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

最热的一天

#012入门循环约 3 分钟

旅行这一周每天记了一个气温。写 hottest(temps),返回最高的那个。至少有一天,气温可能是负的。

示例
hottest({21, 25, 19})→25
hottest({18, 18, 22, 20})→22
函数int hottest(const vector<int> &temps)
main.cpp
#include <vector>
using namespace std;

int hottest(const vector<int> &temps) {
    int best = temps[0];
    for (int t : temps) {
        // 在这里写:t 比 best 高,就换成 t
    }
    return best;
}
Ctrl + Enter 也能运行
结果

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