fork(4) download
  1. #include <iostream>
  2. #include <string>
  3. #include <algorithm>
  4.  
  5. int main() {
  6. std::string str,temp="";
  7. std::getline(std::cin,str,'.');
  8.  
  9. std::for_each(str.rbegin(),str.rend(),
  10. [&temp](auto ch) {
  11. if(ch == ' ')
  12. {
  13. std::cout<<temp<<" ";
  14. temp = "";
  15. }
  16. else
  17. temp = ch+temp;
  18. });
  19. std::cout<<temp<<std::endl;
  20. return 0;
  21. }
Success #stdin #stdout 0s 3460KB
stdin
мама мыла раму.
stdout
раму мыла мама