非常高兴。

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:"杂技"代码

  太高兴了。

posted on 2014-11-18 22:28  小黄驴  阅读(197)  评论(0)    收藏  举报