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

            馬賽克007歡迎你

            htt://shexinwei.blogbus.com

            http://www.shnenglu.com/shexinwei

            感謝大家的支持

            冒泡排序(C++)

            /*
            Subject:      Bubble sort
            Author:       shexinwei
            Date:         2010-09-28
            Laguage:      C++
            IDE | Tool:   GCC(DEV 5.0)
            Version:      1.0
            Modify Time:  2010-09-28
            */   

            #include <cstdlib>
            #include <iostream>
            #include <fstream>
            using namespace std;
            //排序函數
            int Bublle_sort(int data[],int n);
            //打印數組函數
            int print(int data[],int n);
            int main(int argc, char *argv[])
            {
                int data[] = { 2,1,5,3,5,2,6,2};
                int length = sizeof(data)/sizeof(data[0]);
                cout<<"初始序列:"<<endl;
                print(data,length);
                Bublle_sort(data,length);
                cout<<"最終結果:"<<endl;
                print(data,length);
                cout<<endl;
                system("pause");
                return 1;
            }
            int Bublle_sort(int data[],int n)
            {
            int tmp = 0;
            for(int i = 0;i < n;i++)
            {
                for(int j = 0;j < n-i-1;j++)
                {
                        if(data[j]<data[j+1])
                        {
                           tmp = data[j];
                           data[j] = data[j+1];
                           data[j+1] = tmp;
                        }
                        else continue;
                }
                cout<<i+1<<"次排序結果:"<<endl;
                print(data,n);
                cout<<endl;
            }
                return 1;
            }
            int print(int data[],int n)
            {
                for(int i = 0;i < n;i++)
                {
                        cout<<data[i]<<" ";
                }
                        cout<<endl;
            }

            調試結果:


            posted on 2010-09-28 21:46 馬賽克007 閱讀(1720) 評論(0)  編輯 收藏 引用

            <2025年5月>
            27282930123
            45678910
            11121314151617
            18192021222324
            25262728293031
            1234567

            導航

            統計

            公告

            QQ:306334649 本博客所發代碼皆為作者原創,大家可以隨便使用。

            常用鏈接

            留言簿(1)

            隨筆檔案

            文章分類

            我的博客

            搜索

            最新評論

            閱讀排行榜

            評論排行榜

            色青青草原桃花久久综合| 久久综合香蕉国产蜜臀AV| 久久综合一区二区无码| 久久伊人影视| 一本久久a久久精品综合香蕉| 亚洲精品tv久久久久久久久| 久久夜色精品国产噜噜亚洲AV| 久久精品国产99久久无毒不卡| 99久久精品日本一区二区免费| 香蕉久久AⅤ一区二区三区| 国产成人无码精品久久久性色 | 麻豆精品久久久一区二区| 久久婷婷五月综合国产尤物app| 国产亚洲欧美成人久久片| 欧美亚洲国产精品久久| 久久国产精品免费| 亚洲精品无码久久久| 久久综合噜噜激激的五月天| 久久精品国产精品亚洲艾草网美妙| 国产精品久久久久久吹潮| 国产亚洲成人久久| 色妞色综合久久夜夜 | 九九精品久久久久久噜噜| 国产成人久久精品区一区二区| 久久婷婷五月综合色奶水99啪| 久久国产精品久久精品国产| 久久无码中文字幕东京热| 91精品观看91久久久久久| 亚洲欧美伊人久久综合一区二区 | 久久久久久久97| 久久成人精品| 日韩人妻无码精品久久久不卡| 久久综合狠狠综合久久激情 | 久久影视国产亚洲| 99久久99久久精品国产片果冻| 国产成人精品久久亚洲| 久久久久精品国产亚洲AV无码| 久久精品无码一区二区无码 | 99久久国产综合精品网成人影院 | 亚洲国产成人久久精品影视 | 国内精品久久久久影院日本|