美文网首页
SHELL SORT

SHELL SORT

作者: larrymusk | 来源:发表于2017-11-27 19:19 被阅读0次
    void shellsort(int A[], int len)
    {
            int j;
            int increment = len;
            do{
                    increment = increment/3+1;
                    printf("increment = %d\n", increment);
                    for(int i = increment; i < len; i++){
    
                            if(A[i] < A[i-increment]){
                                    int tmp = A[i];
                                    for(j = i-increment; j >= 0 && A[j] >= tmp; j -= increment)
                                            A[j+increment] = A[j];
    
                                    A[j+increment] = tmp;
    
    
                            }
    
                    }
            }while(increment >1);
    
    }
    

    相关文章

      网友评论

          本文标题:SHELL SORT

          本文链接:https://www.haomeiwen.com/subject/coodbxtx.html