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;
}
Input
a b c hola que tal groucho marx zeppo marx aab aaa bbb ccc a aa aaa b bb bbb c cc ccc xyz yz z t zzzzzzzzz Blackbriar!
Output
1 1 1 1 1 0 0 1 0 1 1