156 - Ananagrams (UVA)
题目链接如下:
Online Judge
我的代码如下:
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
// #define debugint main(){#ifdef debugfreopen("0.txt", "r", stdin);freopen("1.txt", "w", stdout);#endifstd::string str;std::vector<std::string> a, b, ans;std::map<std::string, int> mp;while(std::cin >> str && str != "#"){a.push_back(str);transform(str.begin(), str.end(), str.begin(), ::tolower);sort(str.begin(), str.end());b.push_back(str);mp[str]++;}for(int i = 0; i < b.size(); ++i){if(mp[b[i]] == 1){ans.push_back(a[i]);}}sort(ans.begin(), ans.end());for(int i = 0; i < ans.size(); ++i){printf("%s\n", ans[i].c_str());}#ifdef debugfclose(stdin);fclose(stdout);#endifreturn 0;
}