fork download
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9. string str = "I am Mukesh Kumar";
  10. reverse(str.begin(), str.end());
  11.  
  12. string word("");
  13. int length = str.size();
  14.  
  15. for(int i{0}; i<length; i++)
  16. {
  17. if(str.at(i) != 0)
  18. word += str.at(i);
  19. else
  20. {
  21. reverse(word.begin(), word.end());
  22. cout << word << " ";
  23. word = "";
  24. }
  25. }
  26. cout << endl;
  27. return 0;
  28. }
Success #stdin #stdout 0s 4512KB
stdin
Standard input is empty
stdout