fork download
  1. #include <iostream>
  2. #include <string>
  3. //#include <fstream>
  4. #include <sstream>
  5. #include <algorithm>
  6.  
  7. std::string reversed(std::string word) {
  8. std::reverse(word.begin(), word.end());
  9. return word;
  10. }
  11.  
  12. int main() {
  13. //std::ifstream in("input.txt");
  14. //std::ofstream out("output.txt");
  15. std::istream &in = std::cin;
  16. std::ostream &out = std::cout;
  17. std::string line, word;
  18.  
  19. while (std::getline(in, line)) {
  20. std::istringstream iss(line);
  21. if (iss >> word) {
  22. out << reversed(word);
  23. while (iss >> word) {
  24. out << " " << reversed(word);
  25. }
  26. }
  27. out << std::endl;
  28. }
  29.  
  30. return 0;
  31. }
Success #stdin #stdout 0s 15240KB
stdin
Expecting the world to treat you fairly because you are a good person is a little like expecting the bull not to attack you because you are a vegetarian.
stdout
gnitcepxE eht dlrow ot taert uoy ylriaf esuaceb uoy era a doog nosrep si a elttil ekil gnitcepxe eht llub ton ot kcatta uoy esuaceb uoy era a .nairategev