Advertisement
a53

InsertInvers

a53
Dec 5th, 2018
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3. using namespace std;
  4. char cuv[256][256];
  5.  
  6. void invers(int i)
  7. {
  8. int n=strlen(cuv[i]);
  9. for(int j=0;j<n/2;++j)
  10. swap(cuv[i][j],cuv[i][n-1-j]);
  11. }
  12.  
  13. int main()
  14. {
  15. char s[256],*p,separator[]=" ";
  16. cin.getline(s,256);
  17. p=s;
  18. p=strtok(p,separator);
  19. int n=0;
  20. while(p)
  21. {
  22. strcpy(cuv[n],p);
  23. ++n,p=strtok(NULL,separator);
  24. }
  25. for(int i=0;i<n;++i)
  26. cout<<cuv[i]<<' ',invers(i),cout<<cuv[i]<<' ';
  27. cout<<'\n';
  28. return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement