dooooooduo

Untitled

May 10th, 2018
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. void tran(int a[],int k,int n){
  2. if(k >= n)
  3. k = k%n;
  4. reverse(a,0,n-k-1);
  5. reverse(a+(n-k),0,k-1);
  6. reverse(a,0,n-1);
  7. }
  8.  
  9. void reverse(int a[],int s,int e){
  10. int temp;
  11. while(s < e){
  12. temp = a[s];
  13. a[s] = a[e];
  14. a[e] = temp;
  15. s++;
  16. e--;
  17. }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment