D - Ananagrams
作者:
绪方九段
,
2024-10-19 17:26:13
,
所有人可见
,
阅读 11
#include<bits/stdc++.h>
using namespace std;
int main()
{
string str;
set<string> s;
vector<string> v;
map<string,int> mp;
while(cin>>str){
if(str=="#") break;
v.push_back(str);
string t=str;
for (int i = 0; i < t.length(); i++) {
t[i]= tolower(t[i]);
}
sort(t.begin(),t.end());
if (!mp.count(t)) {
mp[t] = 0;
}
mp[t]++;
}
for (int i = 0; i < v.size(); i++) {
string temp = v[i];
for (int j = 0; j < temp.size(); j++) {
temp[j] = tolower(temp[j]);
}
sort(temp.begin(), temp.end());
if (mp[temp] == 1) {
s.insert(v[i]);
}
}
set<string>::iterator it;
for (it = s.begin(); it != s.end(); it++)
{
cout << *it << endl;
}
}