• <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 閱讀(1633) 評論(0)  編輯 收藏 引用 所屬分類: 結構和算法

            久久久久成人精品无码| 久久亚洲AV成人出白浆无码国产| 色综合色天天久久婷婷基地| 99久久亚洲综合精品成人| 欧美与黑人午夜性猛交久久久| 99久久综合国产精品免费| 国产成人久久激情91| 久久这里的只有是精品23| 久久国产亚洲精品麻豆| 久久性精品| 97久久超碰成人精品网站| 久久精品日日躁夜夜躁欧美| 精品国产91久久久久久久a| 久久九九精品99国产精品| 模特私拍国产精品久久| 狠狠精品久久久无码中文字幕| 久久精品黄AA片一区二区三区| 一本久道久久综合狠狠躁AV| 国产叼嘿久久精品久久| 久久国产精品一国产精品金尊| 精品伊人久久大线蕉色首页| 欧美久久亚洲精品| 久久99精品久久久久久野外| 99久久中文字幕| 久久精品无码一区二区无码 | 久久精品国产亚洲av水果派| 日韩影院久久| 久久这里有精品视频| 国内精品久久久久久麻豆| 久久久精品国产亚洲成人满18免费网站 | 亚洲伊人久久综合中文成人网| 久久久久国产一区二区三区| 久久精品国产精品亚洲人人| 一本大道加勒比久久综合| 久久精品9988| 国产高清美女一级a毛片久久w | 久久国产免费直播| 久久久久久亚洲精品无码| 久久婷婷五月综合色奶水99啪| 香港aa三级久久三级老师2021国产三级精品三级在 | 久久久久无码国产精品不卡|