Fes una funció sorted amb la capçalera:
bool sorted(const vector<string>& v);
que retorni cert si el vector està ordenat.
La funció rep un vector de strings, de qualsevol
mida.
La funció retorna true quan el vector està ordenat de
menor a major i retorna false en cas contrari. Si el vector
està buit cal retornar true.
La funció principal que utilitza el Jutge és:
string line, word;
while (getline(cin, line)) {
istringstream S(line);
vector<string> v;
while (S >> word) {
v.push_back(word);
}
cout << sorted(v) << endl;
}
Autoria: Pau Fernández
Generació: 2026-01-25T17:39:11.443Z
© Jutge.org, 2006–2026.
https://jutge.org