fork(3) download
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. void solve(string &s) {
  6. int i = 0;
  7. while (i < s.size()) {
  8. int j = i;
  9. while (j < s.size() && s[j] != ' ')
  10. j++;
  11. int k = i;
  12. i = j + 1;
  13. j--;
  14. while (k < j)
  15. swap(s[k++], s[j--]);
  16. }
  17. cout << s << endl;
  18. }
  19. int main() {
  20. string s;
  21. getline(cin,s);
  22. solve(s);
  23. }
Success #stdin #stdout 0s 5472KB
stdin
damn son where did you find this?
stdout
nmad nos erehw did uoy dnif ?siht