#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;
vector<string>words;
map<string,int>cnt;
string repe(const string& s){
string ans = s;
for(int i = 0 ; i<ans.length() ; i++){
ans[i]=tolower(ans[i]);
}
sort(ans.begin(),ans.end());
return ans;
}
int main()
{
string str1;
string Low;
vector<string>a;
while(cin>>str1){
if(str1[0]=='#') break;
words.push_back(str1);
Low = repe(str1);
if(!cnt.count(Low)) cnt[Low] = 0;
cnt[Low]++;
}
for(int i = 0 ; i<words.size() ; i++){
if(cnt[repe(words[i])] == 1)
a.push_back(words[i]);
}
sort(a.begin(),a.end());
for(int i = 0 ; i<a.size() ; i++){
cout<<a[i]<<"\n";
}
return 0;
}
1.输入的字符串将其先进行标准转换后存放在map中
a.转换成小写字母
b.按照ASCII表进行排序(sort)
问题:
(1)map中的字符都只能出现一次吗?(否)
(2)如果存放在map中不同行的字符串拥有相同数目的字符但是顺序不同可以存储吗?(可以)
(3)是将转换成功后字符串放到map中还是放原字符串?(转换后的)
2.通过字符串搜索map并将其值++1
3.最后数字为1的map中的字符串加入到vector中,并通过sort排序
4.输出