• <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

            我之所以在這里,只是因?yàn)槲蚁胍谶@里

            選擇排序(Windows+VC6.0環(huán)境編譯)

            選擇排序:每一趟從待排序的數(shù)據(jù)元素中選出最小(或最大)的一個(gè)元素,順序放在已排好序的數(shù)列的最后,直到全部待排序的數(shù)據(jù)元素排完。
            時(shí)間復(fù)雜度:O(n的平方)

            下面是我的實(shí)現(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)和算法

            伊人久久五月天| 亚洲国产精品久久66| 99久久99久久精品国产| 国内精品九九久久久精品| 久久久www免费人成精品| 久久久高清免费视频| 久久精品国产亚洲AV影院| 亚洲美日韩Av中文字幕无码久久久妻妇 | 欧美亚洲国产精品久久高清| 麻豆久久| 久久国产欧美日韩精品| 久久精品欧美日韩精品| 久久福利青草精品资源站| 久久精品中文字幕久久| 国产精品成人精品久久久| 久久99精品国产麻豆蜜芽| 久久亚洲国产成人影院网站| 欧美午夜A∨大片久久| 亚洲午夜久久久久妓女影院| 久久婷婷五月综合97色一本一本| 国产精品久久成人影院| 国产成人精品久久亚洲| 天天综合久久一二三区| 久久亚洲私人国产精品| 99久久国产免费福利| 中文字幕久久亚洲一区| 久久精品国产亚洲AV高清热| 久久久国产视频| 午夜不卡久久精品无码免费| 久久久久久人妻无码| 久久精品国产99国产精品澳门| 美女写真久久影院| 久久久久久综合网天天| 久久99精品国产99久久| 久久久久久久免费视频| 久久青青草原国产精品免费| 中文字幕久久精品| 欧美久久精品一级c片片| 伊人久久大香线蕉综合Av| 99久久无码一区人妻| 午夜精品久久久久久久久|