• <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 閱讀(537) 評論(0)  編輯 收藏 引用
            .精品久久久麻豆国产精品| 亚洲精品乱码久久久久久| 久久久久久综合一区中文字幕 | 久久亚洲精品视频| 国产精品xxxx国产喷水亚洲国产精品无码久久一区| 国产精品久久久久久搜索| 久久精品国产精品亜洲毛片| 一本色道久久综合亚洲精品| 26uuu久久五月天| 日本WV一本一道久久香蕉| 日本道色综合久久影院| 无码人妻久久一区二区三区蜜桃| 久久精品国产只有精品2020| 一本大道久久香蕉成人网| 韩国无遮挡三级久久| 99久久国产亚洲综合精品| 久久精品人人做人人爽电影| 中文字幕久久波多野结衣av| 少妇被又大又粗又爽毛片久久黑人 | 亚洲中文字幕无码一久久区| 岛国搬运www久久| 国产精品久久久久久影院| 99精品久久精品一区二区| 亚洲一级Av无码毛片久久精品| 欧美亚洲另类久久综合| 国内精品久久人妻互换| 色综合久久中文字幕无码| 久久精品国产清自在天天线| 久久精品成人免费国产片小草| 91精品国产91久久久久久| www.久久热.com| 国产精品久久久福利| 999久久久无码国产精品| 日韩精品无码久久久久久| 亚洲精品无码久久久久| 国内高清久久久久久| 亚洲国产一成人久久精品| 日韩精品无码久久久久久| 69国产成人综合久久精品| 狠狠色丁香婷婷久久综合不卡| 精品国产福利久久久|