Advertisement
a53

strncat

a53
Jan 20th, 2019
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. char s[1000001];
  8. cin.getline(s,1000);
  9. int n,x,L;
  10. cin>>n;
  11. while(n--)
  12. {
  13. cin>>x;
  14. int j;
  15. L=strlen(s);
  16. if(x%2)
  17. {
  18. j=x;
  19. for(int i=L;i<L+x;++i)
  20. s[i]=s[--j];
  21. s[L+x]=0;
  22. }
  23. else
  24. {
  25. j=0;
  26. for(int i=L;i<L+x;++i)
  27. s[i]=s[j++];
  28. s[L+x]=0;
  29. }
  30. }
  31. cout<<s;
  32. return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement