fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <sstream>
  4. #include <vector>
  5. #include <algorithm>
  6. #include <iterator>
  7.  
  8. using namespace std;
  9.  
  10. int main()
  11. {
  12. string text = "Ala ma czarnego kota";
  13.  
  14. istringstream input(text);
  15. ostringstream output;
  16.  
  17. istream_iterator<string> input_begin(input), input_end;
  18. vector<string> words(input_begin, input_end);
  19. copy(words.rbegin(), words.rend(), ostream_iterator<string>(output, " "));
  20.  
  21. string reversed_text = output.str();
  22.  
  23. cout << reversed_text;
  24. }
Success #stdin #stdout 0s 3068KB
stdin
Standard input is empty
stdout
kota czarnego ma Ala