非常高興。
int vec_rotate(char *vec,int rotdist, int length) { int i,j,k,times; char t; times = gcd(rotdist,length); printf("%d\n",times); for(i=0;i<times;i++) { t = vec[i]; j = i; while(1) { k = j+ rotdist; if(k>=length) k-=length; if(k==i) break; vec[j] = vec[k]; j = k; } vec[j]=t; } return 0; } 向量左旋算法1:"雜技"代碼
太高興了。