日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

映射:map

發(fā)布時間:2025/3/15 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 映射:map 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

2018-5-11

輸入一些單詞,找出滿足以下條件的單詞:
該單詞不能通過字母重排,得到輸入文本中的另外一個單詞。
在判斷是否滿足條件時,字母不區(qū)分大小寫,但在輸出時應該保留輸入中的大小寫,按照字典序進行排列(大寫字母在小寫字母的前面)。

#include<iostream> #include<map> #include<set> #include<vector> #include<string> #include<algorithm> using namespace std;map<string,int>cnt; set<string>fir;string init(string x){for (int i=0;i<x.length();i++){x[i]=tolower(x[i]);}sort(x.begin(),x.end());return x; }int main(){string s,buf;while (cin>>s){if (s[0]=='#') break;fir.insert(s);string tmp=init(s);if (!cnt[tmp]){cnt[tmp]=1;}else{cnt[tmp]++;}}for (set<string>::iterator it=fir.begin();it!=fir.end();it++){if (cnt[init(*it)]==1) cout<<*it<<endl;}return 0; }

總結

以上是生活随笔為你收集整理的映射:map的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。