Advertisement
Guest User

Untitled

a guest
Nov 12th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. #include <iostream>
  2. #include<cstring>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. char s[201];
  8. int i=0,j=0;
  9. cout<<"s=";
  10. cin.getline(s,201);
  11. while(j<strlen(s))
  12. {
  13. while(s[j]!='\0'&&s[j]!=' ')
  14. j++;
  15. if((j-i)%2!=0)
  16. {
  17. if(j-i>1)
  18. {
  19. strcpy(s+(j-i)/2+i,s+(j-i)/2+1+i);
  20. i=j;
  21. }
  22. else
  23. i=j=j+1;
  24. }
  25. else
  26. {
  27. if(j-i>2)
  28. {
  29. strcpy(s+(j-i)/2+i-1,s+(j-i)/2+i);
  30. strcpy(s+i+(j-i)/2-1,s+i+(j-i)/2);
  31. i=j=j-1;
  32. }
  33. else
  34. i=j=j+1;
  35. }
  36.  
  37. }
  38. cout<<s;
  39. return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement