A noite de boliche teve várias partidas, e scores guarda a pontuação de cada uma; há pelo menos uma. low_high devolve a menor e a maior por duas referências, low e high. Complete o laço: qualquer uma menor substitui low, qualquer uma maior substitui high.
score_range({120, 98, 145, 110})→'98 ~ 145'score_range({77})→'77 ~ 77'string score_range(const vector<int> &scores)#include <string>
#include <vector>
using namespace std;
void low_high(const vector<int> &scores, int &low, int &high) {
low = scores[0];
high = scores[0];
for (int s : scores) {
// seu código aqui: menor substitui low, maior substitui high
}
}
string score_range(const vector<int> &scores) {
int low = 0, high = 0;
low_high(scores, low, high);
return to_string(low) + " ~ " + to_string(high);
}
Executar testa os exemplos. Quando parecerem certos, Enviar.