fork(1) download
  1. #include <iostream>
  2. #include <cctype>
  3.  
  4. std::istream& reverse_word(std::istream& in, std::ostream& out)
  5. {
  6. char ch;
  7.  
  8. if (in.get(ch) && !std::isspace(ch))
  9. {
  10. reverse_word(in, out);
  11. out << ch;
  12. }
  13.  
  14. return in;
  15. }
  16.  
  17. int main()
  18. {
  19. for (unsigned i = 0; i < 5; ++i)
  20. {
  21. reverse_word(std::cin, std::cout);
  22. std::cout << '\n';
  23. }
  24. }
Success #stdin #stdout 0s 3300KB
stdin
gigantic thesaurus mota nosaert sdrawkcab
stdout
citnagig
suruaseht
atom
treason
backwards