• <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>
            posts - 183,  comments - 10,  trackbacks - 0

            不同組的組合

            有 N 個組,每個組中有不定個元素,從每個組中選擇一個元素,例如:
            第一組 1 2
            第二組 3 4
            第三組 5
            結果為:
            1 3 5
            1 4 5
            2 3 5
            2 4 5

            http://topic.csdn.net/u/20100313/23/51e49d61-8a36-47f5-8e3b-20477dafde55.html

             1 #include <iostream>
             2 #include <string>
             3 #include <vector>
             4 using namespace std;
             5 
             6 void foo(vector<vector<string> >& result, vector<string>& temp, const vector<vector<string> >& vvs, size_t m)
             7 {
             8     if (temp.size() >= vvs.size())
             9     {
            10         result.push_back(temp);
            11         for (size_t i = 0; i != temp.size(); ++i)
            12         {
            13             cout << temp[i] << ' ';
            14         }
            15         cout << endl;
            16     }
            17     else
            18     {
            19         for (size_t i = 0; i != vvs[m].size(); ++i)
            20         {
            21             temp.push_back(vvs[m][i]);
            22             foo(result, temp, vvs, m + 1);
            23             temp.pop_back();
            24         }
            25     }
            26 }
            27 
            28 void bar(vector<vector<string> >& result, const vector<vector<string> >& vvs)
            29 {
            30     vector<string> temp;
            31     foo(result, temp, vvs, 0);
            32 }
            33 
            34 int main()
            35 {
            36     vector<vector<string> > vvs;
            37     vector<string> vs;
            38     vs.push_back("A1");
            39     vs.push_back("A2");
            40     vvs.push_back(vs);
            41     vs.clear();
            42     vs.push_back("B1");
            43     vs.push_back("B2");
            44     vvs.push_back(vs);
            45     vs.clear();
            46     vs.push_back("C1");
            47     vs.push_back("C2");
            48     vs.push_back("C3");
            49     vvs.push_back(vs);
            50     vs.clear();
            51     for (size_t i = 0; i != vvs.size(); ++i)
            52     {
            53         for (size_t j = 0; j != vvs[i].size(); ++j)
            54         {
            55             cout << vvs[i][j] << ' ';
            56         }
            57         cout << endl;
            58     }
            59     cout << endl;
            60     vector<vector<string> > result;
            61     bar(result, vvs);
            62     cout << endl;
            63     for (size_t i = 0; i != result.size(); ++i)
            64     {
            65         for (size_t j = 0; j != result[i].size(); ++j)
            66         {
            67             cout << result[i][j] << ' ';
            68         }
            69         cout << endl;
            70     }
            71     return 0;
            72 }


            posted on 2011-10-06 13:23 unixfy 閱讀(172) 評論(0)  編輯 收藏 引用
            久久久久高潮毛片免费全部播放 | 婷婷久久综合| AV色综合久久天堂AV色综合在| 亚洲精品白浆高清久久久久久| 久久99精品久久只有精品| 久久精品国产亚洲77777| 999久久久国产精品| 免费精品久久天干天干| 久久久精品人妻一区二区三区四 | 久久男人中文字幕资源站| 一本色道久久综合亚洲精品| 办公室久久精品| 99精品国产99久久久久久97| 国产午夜免费高清久久影院| 久久精品成人免费国产片小草| 狠狠88综合久久久久综合网| 国产激情久久久久影院| 久久久一本精品99久久精品66 | 思思久久99热免费精品6| 久久夜色精品国产噜噜亚洲AV| 久久se精品一区精品二区国产 | 精品久久久久久中文字幕大豆网 | 99久久99这里只有免费费精品| 99久久综合狠狠综合久久止| 亚洲日韩欧美一区久久久久我| 99久久精品免费| 色欲久久久天天天综合网| 精品国产一区二区三区久久蜜臀| 老色鬼久久亚洲AV综合| 亚洲国产日韩欧美综合久久| 久久夜色tv网站| 国产精品久久久久久久久免费| 国产成人无码精品久久久性色| 性高湖久久久久久久久AAAAA| 91精品国产91久久久久久| 2022年国产精品久久久久| 亚洲国产精品无码久久久不卡 | 日本欧美国产精品第一页久久| 国产69精品久久久久99尤物| 国产成人久久777777| 亚洲国产成人久久精品动漫|