• <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環境編譯)

            選擇排序:每一趟從待排序的數據元素中選出最小(或最大)的一個元素,順序放在已排好序的數列的最后,直到全部待排序的數據元素排完。
            時間復雜度:O(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 閱讀(362) 評論(0)  編輯 收藏 引用 所屬分類: 結構和算法

            天天爽天天狠久久久综合麻豆| 精品无码久久久久久久久久| 欧美一区二区三区久久综 | 国产精品亚洲美女久久久| 久久久久久国产精品无码下载| 久久中文字幕精品| 51久久夜色精品国产| 91麻豆国产精品91久久久| 国产精品久久久久影视不卡| 日本五月天婷久久网站| 久久综合丝袜日本网| 亚洲中文字幕久久精品无码喷水| 日本免费久久久久久久网站| 久久久久AV综合网成人| 久久成人小视频| 国内精品免费久久影院| 久久66热人妻偷产精品9| 亚洲色婷婷综合久久| 伊人久久大香线蕉综合5g| 久久av高潮av无码av喷吹| 91精品国产91久久久久福利| 亚洲精品午夜国产VA久久成人| 久久伊人亚洲AV无码网站| 99热精品久久只有精品| 99久久综合狠狠综合久久| 成人综合伊人五月婷久久| 亚洲va久久久噜噜噜久久| 久久久久久伊人高潮影院| 久久毛片一区二区| 伊人久久大香线蕉综合网站| 久久性精品| 久久人妻少妇嫩草AV蜜桃| 久久精品国产2020| 精品久久久久久国产| 久久精品天天中文字幕人妻| 久久久久久国产精品无码超碰| 久久午夜伦鲁片免费无码| 久久九九青青国产精品| 青青青国产精品国产精品久久久久 | 亚洲精品成人网久久久久久| 香蕉久久夜色精品国产2020|