算法竞赛入门经典第五章例题5-4 Ananagrams UVA - 156

https://vjudge.net/problem/UVA-156

#include
#include
#include
#include
#include
using namespace std;
#pragma warning(disable:4996)
string normal(string s) {
    for (auto &x : s)
        x = tolower(x);
    sort(s.begin(), s.end());
    return s;
}
int main()
{
#ifdef _DEBUG
    //freopen("in", "rb", stdin);
    //freopen("out", "wb", stdout);
#endif // _DEBUG
    map<string, int> cnt;
    vector<string> words,ans;
    string s;
    while (cin >> s && s!="#")
        ++cnt[normal(s)],words.push_back(s);
    for (auto x : words)
        if (cnt[normal(x)] == 1) ans.push_back(x);
    sort(ans.begin(), ans.end());
    for (auto x : ans)
        cout << x << endl;
}

你可能感兴趣的:(算法竞赛入门经典第五章例题5-4 Ananagrams UVA - 156)