fork download
  1. #include <iostream>
  2. #include<stdio.h>
  3. #include<string.h>
  4. using namespace std;
  5.  
  6. int main() {
  7. // your code goes here
  8. int c,test;
  9. cin>>test;
  10. // c=getchar();
  11. test=test+1;
  12. while(test--){
  13. char str[105];
  14. int len=0;
  15. cin.getline(str,105);
  16. len=strlen(str);
  17. int idx=0;
  18.  
  19. for(int i=0;i<len;i++)
  20. {
  21.  
  22. if(str[i]==' ')
  23. {
  24. for(int j=i-1;j>=idx;j--)
  25. cout<<str[j];
  26.  
  27. cout<<" ";
  28. idx=i+1;
  29. }
  30. }
  31. for(int i=len-1;i>=idx;i--)
  32. cout<<str[i];
  33. cout<<endl;
  34. }
  35. return 0;
  36. }
Success #stdin #stdout 0s 3100KB
stdin
3
qwema ddja dkaka 
qwerty 
asfkdsajf sflajlidj
stdout
amewq ajdd akakd 
ytrewq 
fjasdkfsa jdiljalfs