fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4. #include <sstream>
  5. #include <algorithm>
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10. string input;
  11. getline(cin, input);
  12. cout << "Vorher: " << input << '\n';
  13.  
  14. vector<string> words;
  15. stringstream wordparser(input);
  16. for(string word; wordparser >> word; )
  17. words.push_back(word);
  18. sort(words.begin(), words.end());
  19.  
  20. stringstream outputstream;
  21. for(const string& word: words)
  22. outputstream << word << ' ';
  23.  
  24. string result = outputstream.str();
  25. cout <<"Nachher: " << result << '\n';
  26. }
Success #stdin #stdout 0s 3440KB
stdin
cTest aaa xyz abcd Abcd usw bWort
stdout
Vorher: cTest aaa xyz abcd Abcd usw bWort
Nachher: Abcd aaa abcd bWort cTest usw xyz