• <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 閱讀(532) 評論(0)  編輯 收藏 引用
            一本色道久久综合狠狠躁| 亚洲成av人片不卡无码久久 | 91精品国产综合久久香蕉| 久久综合亚洲鲁鲁五月天| 久久久久99精品成人片| 国产精品久久久久乳精品爆 | 精品久久久久久中文字幕大豆网| 国产高潮久久免费观看| 99久久国产热无码精品免费久久久久| 久久99国内精品自在现线| 久久ZYZ资源站无码中文动漫| 无码专区久久综合久中文字幕| 狠狠色狠狠色综合久久| 一本久久知道综合久久| 中文国产成人精品久久不卡| 久久人人爽人人爽人人片av麻烦 | 免费观看久久精彩视频| 一本久久a久久精品综合夜夜| 99久久无码一区人妻| 国产精品99久久久久久董美香| 国产69精品久久久久9999| 久久久久无码精品国产app| 伊人伊成久久人综合网777| 久久AV无码精品人妻糸列| www性久久久com| 久久精品国产99久久久香蕉| 久久受www免费人成_看片中文| 亚洲AV无码久久| 99久久免费只有精品国产| 亚洲午夜精品久久久久久app| 无码人妻久久一区二区三区免费 | 久久亚洲国产午夜精品理论片| 九九热久久免费视频| 久久久久久国产a免费观看黄色大片| 伊人久久大香线焦AV综合影院| 99久久精品影院老鸭窝| 香蕉99久久国产综合精品宅男自| 国内精品久久久久影院薰衣草| 日韩精品久久久久久| 亚洲精品无码久久久影院相关影片| 97精品国产91久久久久久|