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

            逛奔的蝸牛

            我不聰明,但我會很努力

               ::  :: 新隨筆 ::  ::  :: 管理 ::
            #include <iostream>
            #include 
            <ctime>
            #include 
            <cmath>

            void quickSort(int *array, int first, int last) {
                
            if (first >= last) {
                    
            return;
                }
                
                
            int referenceValue = array[(first + last) / 2];
                
            int i = first;
                
            int j = last;
                
                
            while (i <= j) {
                    
            while (i <= last && array[i] < referenceValue) {
                        
            ++i;
                    }
                    
            while (j >= first && array[j] > referenceValue) {
                        
            --j;
                    }
                    
                    
            if (i <= j) {
                        
            int temp = array[i];
                        array[i] 
            = array[j];
                        array[j] 
            = temp;
                        
                        
            ++i;
                        
            --j;
                    }
                }
                
                quickSort(array, first, j);
                quickSort(array, i, last);
            }

            void selectSort(int *array, int length) {
                
            for (int i = 0; i < length - 1++i) {
                    
            for (int k = i + 1; k < length; ++k) {
                        
            if (array[k] < array[i]) {
                            
            int temp = array[i];
                            array[i] 
            = array[k];
                            array[k] 
            = temp;
                        }
                    }
                }
            }

            void sort(int *array, int length) {
                
            if (length < 30) {
                    selectSort(array, length);
                } 
            else {
                    quickSort(array, 
            0, length - 1);
                }
            }

            int main() {
                srand(time(
            0));
                
            int length = 0;
                
                
            for (int count = 0; count < 20++count) {
                    length 
            = rand() % 50;
                    
            int *array = new int[length];
                    
            for (int i = 0; i < length; ++i) {
                        
            *(array + i) = rand() % 500;
                    }
                    
                    sort(array, length);
                    
                    
            for (int i = 0; i < length; ++i) {
                        std::cout 
            << array[i] << "";
                    }
                    
                    delete[] array;
                    
                    std::cout 
            << std::endl;
                }
                
                
            return 0;
            }


            posted on 2008-04-08 18:27 逛奔的蝸牛 閱讀(157) 評論(0)  編輯 收藏 引用 所屬分類: C/C++
            欧美一级久久久久久久大片| 午夜人妻久久久久久久久| AV无码久久久久不卡蜜桃| 97久久久久人妻精品专区| 久久99国产精品99久久| 久久久综合香蕉尹人综合网| 久久久久久久精品妇女99| 久久经典免费视频| 久久夜色精品国产噜噜噜亚洲AV | 久久这里只有精品首页| 奇米影视7777久久精品| 久久国产视屏| 91久久精一区二区三区大全| 九九99精品久久久久久| 亚洲国产成人精品91久久久| 国产精品无码久久久久久| 久久国产精品二国产精品| 久久免费看黄a级毛片| 很黄很污的网站久久mimi色| 亚洲AV无码1区2区久久| 亚洲精品99久久久久中文字幕 | 香蕉aa三级久久毛片| 99精品国产在热久久| 久久国产欧美日韩精品| 国产99久久久国产精品~~牛| 久久天天躁狠狠躁夜夜avapp| 亚洲AV伊人久久青青草原| 伊人久久大香线焦综合四虎| 久久久亚洲欧洲日产国码aⅴ| 亚洲欧美成人久久综合中文网 | 久久婷婷五月综合97色| 一本大道久久东京热无码AV| 久久久久97国产精华液好用吗| 韩国三级大全久久网站| 亚洲精品无码久久一线| 亚洲午夜久久久久久久久电影网| 久久九九久精品国产免费直播| 久久99精品九九九久久婷婷| 久久精品二区| 亚洲国产成人久久综合区| 午夜精品久久久久久影视riav|