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

            一個字符串集合

            {"...", "...", ... }

            找到相同的字符串,這樣的字符串是:包含的字符相同,字符的個數也相同

            解決方案:
            先對每個字符串排序
            然后對排完序的字符串整體排序
            遍歷整個字符串集合,即可得到結果

             1 #include <iostream>
             2 #include <vector>
             3 #include <map>
             4 #include <string>
             5 #include <algorithm>
             6 using namespace std;
             7 
             8 int main()
             9 {
            10     vector<string> data;
            11     data.push_back("cafe");
            12     data.push_back("baidu");
            13     data.push_back("duiba");
            14     data.push_back("thisone");
            15     data.push_back("iseasy");
            16     data.push_back("esayis");
            17     data.push_back("siesay");
            18     data.push_back("esaysi");
            19 
            20     multimap<stringstring> mem;
            21     for (vector<string>::size_type i = 0; i != data.size(); ++i)
            22     {
            23         string tmp(data[i]);
            24         sort(tmp.begin(), tmp.end());
            25         mem.insert(make_pair(tmp, data[i]));
            26     }
            27     if (mem.size() <= 1)
            28     {
            29         return 0;
            30     }
            31     for (multimap<stringstring>::const_iterator cit = mem.begin(); cit != mem.end(); ++cit)
            32     {
            33         cout << cit->first << '\t' << cit->second << endl;
            34     }
            35     cout << "===================" << endl;
            36     multimap<stringstring>::const_iterator cit1, cit2, cit3;
            37     cit1 = mem.begin();
            38     cit3 = cit1;
            39     cit2 = ++cit3;
            40     bool f = false;
            41     while (cit2 != mem.end())
            42     {
            43         if (cit1->first == cit2->first)
            44         {
            45             if (!f)
            46             {
            47                 f = true;
            48                 cout << cit1->first << '(' << cit1->second << ')' << '\t' << cit2->first << '(' << cit2->second << ')' << '\t';
            49             }
            50             else
            51             {
            52                 cout << cit2->first << '(' << cit2->second << ')' << '\t';
            53             }
            54         }
            55         else
            56         {
            57             if (f)
            58             {
            59                 cout << endl;
            60                 f = false;
            61             }
            62         }
            63         ++cit1;
            64         ++cit2;
            65     }
            66     return 0;
            67 }
            68 

             


            posted on 2011-07-11 13:34 unixfy 閱讀(534) 評論(0)  編輯 收藏 引用
            色综合久久夜色精品国产 | 久久精品国产亚洲AV无码偷窥| 久久天天躁狠狠躁夜夜2020老熟妇 | 精品久久人人爽天天玩人人妻| 99久久国产综合精品麻豆| 亚洲国产天堂久久综合网站| 久久夜色精品国产噜噜亚洲a| 久久人人爽人人爽人人片AV东京热| A级毛片无码久久精品免费| 免费精品久久久久久中文字幕 | 麻豆成人久久精品二区三区免费| 精品久久人人爽天天玩人人妻| 性做久久久久久久| 久久久久亚洲av综合波多野结衣| 国产精品对白刺激久久久| 天天爽天天狠久久久综合麻豆| 久久久久国产精品| 91久久精品国产免费直播| 久久久SS麻豆欧美国产日韩| 久久激情五月丁香伊人| 国产激情久久久久影院| 日本免费久久久久久久网站| 久久精品中文无码资源站| 四虎影视久久久免费| 一本色道久久88综合日韩精品| 久久亚洲国产精品五月天婷| 久久精品毛片免费观看| 99蜜桃臀久久久欧美精品网站| 久久综合九色综合久99| 精品久久久久中文字| 狠狠精品久久久无码中文字幕 | 久久久久九国产精品| 免费国产99久久久香蕉| 国产精品视频久久| 久久国产精品久久国产精品| 久久天天躁狠狠躁夜夜2020| 久久亚洲色一区二区三区| 免费精品久久久久久中文字幕| 久久综合色之久久综合| 人人狠狠综合久久亚洲| 亚洲精品午夜国产va久久|