fork download
  1. #include <stdio.h>
  2. #define N 10
  3.  
  4. void pp(int*a,int n)
  5. {
  6. while(n--)printf("%d ",*a++);
  7. putchar('\n');
  8. }
  9.  
  10. int main()
  11. {
  12. int i,j,k,t,a[N];
  13. for(i=0; i<N; i++)a[i]=i*11;
  14.  
  15. pp(a,N);
  16. for(i=10,j=0; --i;) {
  17. j=j<N/2?(j*2+1)%N:(j*2)%N;
  18. t=a[0];
  19. a[0]=a[j];
  20. a[j]=t;
  21. }
  22. pp(a,N);
  23.  
  24. return 0;
  25. }
Success #stdin #stdout 0.02s 1720KB
stdin
Standard input is empty
stdout
0 11 22 33 44 55 66 77 88 99 
55 0 66 11 77 22 88 33 99 44