• <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)和算法

            久久人妻少妇嫩草AV蜜桃| 2020久久精品国产免费| 久久久久久毛片免费看| 久久九色综合九色99伊人| 欧美精品九九99久久在观看| 亚洲AV无码久久| 久久久久亚洲精品中文字幕| 无码精品久久久久久人妻中字| 国产精品久久网| 狠狠色丁香久久婷婷综合| 91精品国产91久久久久久青草 | 欧美伊香蕉久久综合类网站| 久久久精品人妻无码专区不卡| 亚洲va久久久噜噜噜久久男同| 国产精品午夜久久| 久久久国产精品网站| 亚洲中文字幕久久精品无码APP| 国产成人精品久久亚洲| 2021久久国自产拍精品| 亚洲国产另类久久久精品黑人| 国产综合成人久久大片91| 精品久久久久久久久午夜福利| 国产精品久久新婚兰兰| 一本久久综合亚洲鲁鲁五月天| 91性高湖久久久久| 97精品伊人久久久大香线蕉| 精品999久久久久久中文字幕| 人妻无码αv中文字幕久久琪琪布 人妻无码久久一区二区三区免费 人妻无码中文久久久久专区 | 久久久久人妻一区精品色| 一级a性色生活片久久无| 日本久久中文字幕| 久久久久99精品成人片牛牛影视| 久久天堂电影网| 99久久99久久精品国产片| 亚洲国产精品久久久久久| 人人狠狠综合久久亚洲婷婷| 中文精品久久久久国产网址| 久久国产精品免费一区| 久久中文字幕视频、最近更新| 久久久精品国产亚洲成人满18免费网站 | 久久香蕉国产线看观看99|