Kodewick
Start learning →
Starter←→0 / 60

Hottest day

#012StarterLoops3 min

You noted one temperature for each day of a week away. Write hottest(temps) to return the highest one. There is at least one day, and temperatures can be below zero.

Examples
hottest({21, 25, 19})→25
hottest({18, 18, 22, 20})→22
The functionint 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) {
        // your code here: if t is higher than best, make best t
    }
    return best;
}
Ctrl + Enter runs too
Result

Run tries the examples. When they look right, Submit.