• <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ù)元素中選出最小(或最大)的一個元素,順序放在已排好序的數(shù)列的最后,直到全部待排序的數(shù)據(jù)元素排完。
            時間復(fù)雜度:O(n的平方)

            下面是我的實現(xiàn)(代碼僅供參考,各位有意見請指出):

             1#include <stdio.h>
             2#include <cstdlib>
             3
             4#define TOTAL_NUM 10000
             5#define MAX_NUM 1000
             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 min = Sort[i];
            28        int index = i;
            29        bool bSet = false;
            30        for (int j=i;j<TOTAL_NUM;j++)
            31        {
            32            if (min>Sort[j])
            33            {                
            34                min = Sort[j];
            35                index = j;
            36                if (!bSet)bSet = true;
            37            }

            38        }

            39        if (bSet)
            40        {
            41            Sort[index] = Sort[i];
            42            Sort[i] = min;
            43        }

            44    }

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

            56    }

            57
            58    getchar();
            59    return 0;
            60}

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

            色欲久久久天天天综合网精品| 亚洲国产一成久久精品国产成人综合 | 久久中文字幕人妻熟av女| 亚洲第一永久AV网站久久精品男人的天堂AV | 亚洲国产精品久久久久网站 | 久久夜色精品国产噜噜麻豆| 蜜臀久久99精品久久久久久小说| 久久久久久久尹人综合网亚洲| 久久精品国产72国产精福利| 一本一本久久aa综合精品| 7国产欧美日韩综合天堂中文久久久久| 久久亚洲AV无码西西人体| 久久综合噜噜激激的五月天| 国产成人无码精品久久久久免费| 久久精品国产免费观看| 99久久国产综合精品网成人影院 | 久久成人国产精品免费软件| 四虎国产精品免费久久5151| 少妇人妻综合久久中文字幕| 99久久精品免费看国产一区二区三区 | 亚洲国产精品无码久久久蜜芽| 国产日韩久久免费影院| 91精品国产综合久久精品| 奇米影视7777久久精品人人爽| 久久精品成人| 久久精品女人天堂AV麻| 日本精品久久久久中文字幕8 | 久久精品99久久香蕉国产色戒 | 久久久久综合网久久| 国产色综合久久无码有码| 日本精品久久久久影院日本| 久久99精品久久久久久秒播| 91久久福利国产成人精品| 久久天堂电影网| 青青青青久久精品国产 | 亚洲精品99久久久久中文字幕 | 久久久久av无码免费网| 亚洲精品无码专区久久同性男 | 国产精品久久久久9999| 久久99国内精品自在现线| 久久久噜噜噜久久熟女AA片|