• <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環(huán)境編譯)

            插入排序:每次將一個待排序的數(shù)據(jù)元素,插入到前面已經(jīng)排好序的數(shù)列中的適當(dāng)位置,使數(shù)列依然有序;直到待排序數(shù)據(jù)元素全部插入完為止。
            時間復(fù)雜度:O(n的平方)
             1#include <stdio.h>
             2#include <cstdlib>
             3
             4#define TOTAL_NUM 1000
             5#define MAX_NUM 100
             6
             7int main(int argc,char* argv[])
             8{
             9    int Sort[TOTAL_NUM];
            10    
            11    int iPrintCount = 0;
            12    int i = 0;
            13    printf("::: old order ::: \n");    
            14    for (i=0;i<TOTAL_NUM;i++)
            15    {
            16        Sort[i] = (rand()+MAX_NUM)%MAX_NUM;
            17        printf("%5ld ",Sort[i]);    
            18        if(++iPrintCount==10)
            19        {
            20            iPrintCount = 0;
            21            printf("\n");
            22        }

            23    }

            24    
            25    for (i=0;i<TOTAL_NUM;i++)
            26    {
            27        int iVal = Sort[i];                
            28        if (iVal<Sort[0])
            29        {
            30            for(int k=i;k>0;k--)
            31                Sort[k] = Sort[k-1];                                
            32            Sort[0= iVal;
            33        }
            else
            34        {
            35            for (int j=0;j<i;j++)
            36            {            
            37                if (iVal>=Sort[j] && iVal<Sort[j+1])
            38                {    
            39                    for(int k=i;k>j+1;k--)
            40                        Sort[k] = Sort[k-1];                
            41                    Sort[j+1= iVal;
            42                    break;
            43                }

            44            }

            45        }
                            
            46    }

            47    
            48    iPrintCount = 0;
            49    printf("\n::: new order ::: \n");    
            50    for (i=0;i<TOTAL_NUM;i++)
            51    {        
            52        printf("%5ld ",Sort[i]);    
            53        if(++iPrintCount==10)
            54        {
            55            iPrintCount = 0;
            56            printf("\n");
            57        }

            58    }

            59    
            60    getchar();
            61    return 0;
            62}


            posted on 2009-07-20 23:48 xmoss 閱讀(459) 評論(0)  編輯 收藏 引用 所屬分類: 結(jié)構(gòu)和算法

            久久精品国产99国产电影网| 99蜜桃臀久久久欧美精品网站| www性久久久com| 久久久久夜夜夜精品国产| 青草久久久国产线免观| 久久久亚洲欧洲日产国码二区| 亚洲国产二区三区久久| 亚洲色大成网站www久久九| 国产精品一区二区久久精品无码| 偷偷做久久久久网站| 欧美日韩中文字幕久久伊人| 久久精品青青草原伊人| 欧美伊人久久大香线蕉综合69| 国内精品久久久久影院日本| 国产精品成人久久久| 久久久久亚洲?V成人无码| 国产91色综合久久免费| 亚洲午夜久久久影院伊人| 日日狠狠久久偷偷色综合0| 久久国产一区二区| 久久精品国产久精国产思思| 99久久精品免费看国产一区二区三区 | 久久久国产亚洲精品| 欧美亚洲国产精品久久蜜芽| 久久久精品人妻一区二区三区蜜桃| 久久久精品国产Sm最大网站| 天天爽天天爽天天片a久久网| 国产免费久久精品99re丫y| 亚洲国产成人精品女人久久久 | 2020国产成人久久精品| 亚洲国产成人久久笫一页| 久久精品亚洲欧美日韩久久| 品成人欧美大片久久国产欧美...| 麻豆成人久久精品二区三区免费| 波多野结衣久久一区二区| 久久人人爽人人爽人人片AV高清| 久久人人爽人人爽人人片AV东京热| 日本久久久久久中文字幕| 日本精品久久久久中文字幕| 一本伊大人香蕉久久网手机| 精品国产综合区久久久久久|