• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            JUST DO IT

            我之所以在這里,只是因為我想要在這里

            希爾排序(Windows+VC6.0環境編譯)

            希爾排序基本思想是:先取一個小于n的整數d1作為第一個增量,把文件的全部記錄分成d1個組。所有距離為dl的倍數的記錄放在同一個組中。先在各組內進行直接插入排序;然后,取第二個增量d2<d1重復上述的分組和排序,直至所取的增量dt=1(dt<dt-l<…<d2<d1),即所有記錄放在同一組中進行直接插入排序為止。該方法實質上是一種分組插入方法。
             1#include <stdio.h>
             2#include <cstdlib>
             3
             4#define TOTAL_NUM 100
             5#define MAX_NUM 200
             6
             7int shell_sort(int sort[],int increment)
             8{    
             9    for (int i=0;i<increment;i++)
            10    {
            11        for (int j=i+increment;j<TOTAL_NUM;j+=increment)
            12        {
            13            int iNum = sort[j];
            14            if (iNum>=sort[j-increment])continue;
            15            int k = 0;
            16              for (k=j-increment;k>=0;k-=increment)
            17              {
            18                  if (sort[k]>iNum)
            19                {
            20                    sort[k+increment] = sort[k];                    
            21                }
            else 
            22                {
            23                    sort[k] = iNum;
            24                    break;
            25                }

            26              }
                          
            27        }

            28    }
                
            29    return 0;
            30}

            31
            32void SORT(int sort[])
            33{
            34    int incre = TOTAL_NUM;
            35    do{
            36        incre = incre/4+1;
            37        shell_sort(sort,incre);
            38    }
            while (incre>1);    
            39}

            40
            41int main(int argc,char* argv[])
            42{
            43    int Sort[TOTAL_NUM];
            44    
            45    int iPrintCount = 0;
            46    int i = 0;
            47    printf("::: old order ::: \n");    
            48    for (i=0;i<TOTAL_NUM;i++)
            49    {
            50        Sort[i] = (rand()+MAX_NUM)%MAX_NUM;
            51        printf("%5ld ",Sort[i]);    
            52        if(++iPrintCount==10)
            53        {
            54            iPrintCount = 0;
            55            printf("\n");
            56        }

            57    }

            58    
            59    //shell sort
            60    SORT(Sort);
            61    
            62    iPrintCount = 0;
            63    printf("\n::: new order ::: \n");    
            64    for (i=0;i<TOTAL_NUM;i++)
            65    {        
            66        printf("%5ld ",Sort[i]);    
            67        if(++iPrintCount==10)
            68        {
            69            iPrintCount = 0;
            70            printf("\n");
            71        }

            72    }

            73    
            74    getchar();
            75    return 0;
            76}

            posted on 2009-07-29 23:06 xmoss 閱讀(1622) 評論(0)  編輯 收藏 引用 所屬分類: 結構和算法

            亚洲欧美日韩精品久久| 中文字幕无码久久人妻| 久久99亚洲网美利坚合众国| 国产91色综合久久免费分享| 久久精品国产免费| 久久久久亚洲爆乳少妇无| 久久久久高潮综合影院| 91久久精品无码一区二区毛片| 久久久久无码精品| 国产成人久久AV免费| 久久亚洲高清综合| 久久国产欧美日韩精品| 中文字幕无码av激情不卡久久| 久久精品国产99国产精偷| 亚洲一区精品伊人久久伊人| 99久久777色| 精品综合久久久久久98| 久久久人妻精品无码一区| 久久精品麻豆日日躁夜夜躁| 久久香蕉国产线看观看猫咪?v| 久久久精品2019免费观看| 欧美久久久久久| 久久久久99精品成人片| 嫩草影院久久国产精品| 久久婷婷国产综合精品| 亚洲愉拍99热成人精品热久久| 久久久久亚洲AV成人网人人网站| 久久99国产亚洲高清观看首页| 精品久久久久久中文字幕大豆网| 久久综合给合综合久久| 精品99久久aaa一级毛片| 国产精品欧美久久久天天影视| 婷婷五月深深久久精品| 模特私拍国产精品久久| 欧美一级久久久久久久大片| 国产亚州精品女人久久久久久| 91久久精品国产成人久久| 国产综合成人久久大片91| 激情五月综合综合久久69| 久久免费视频一区| 亚洲精品成人久久久|