[算法]希尔排序

 
        int arry[]={1,4,9,4,8,2,7,43,3,2};
        int acount=sizeof(arry);
        int aocount=sizeof(arry[0]);
        int n=(acount/aocount);
     
        int k;
        k=n/2;
        int t;
        while(k>0)
        {
            for(i=k;i<n;i++)
         {  
            t=arry[i];
            j=i-k;
           while(j>=0&&t<arry[j])
             {
                 arry[j+k]=arry[j];
                 j=j-k;
             }
             arry[j+k]=t;
          }
             k/=2;
        }
      for (int i=0;i<n;i++) {
            printf("%d",arry[i]);
        }

posted @ 2013-03-25 23:08  金建彤  阅读(114)  评论(0编辑  收藏  举报