Està ordenat?

Fes una funció sorted amb la capçalera:

       bool sorted(const vector<string>& v);

que retorni cert si el vector està ordenat.

Entrada

La funció rep un vector de strings, de qualsevol mida.

Sortida

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.

Observació

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;
      }

Informació del problema

Autoria: Pau Fernández

Generació: 2026-01-25T16:55:49.481Z

© Jutge.org, 2006–2026.
https://jutge.org
