dddd

 1 int vec_rotate(char *vec,int rotdist, int length) {
 2 int i,j,k,times;
 3 char t;
 4 times = gcd(rotdist,length);
 5  printf("%d\n",times);
 6 for(i=0;i<times;i++) {
 7  t = vec[i];
 8   j = i;
 9    while(1) {
10  k = j+ rotdist;
11  if(k>=length)
12   k-=length;
13  if(k==i)
14 break;
15  vec[j] = vec[k];
16 j = k;
17 }
18  vec[j]=t;
19     }
20     return 0;
21 }
22 
23 向量左旋算法1:"杂技"代码
View Code

eee

posted on 2014-11-18 22:35  小黄驴  阅读(226)  评论(0编辑  收藏  举报