题目意思,简单来说就是
输入:一段文本
操作:提取文本中满足某些条件的单词
条件:该单词的字母重新排列后不会与文本中的任意一个单词相同,此时的比较不分大小写(意思就是将所有字母转成全大写或全小写,就是要规范,但最后输出还是要输出原单词,就是规范化以前的单词)
输出:按字典序排列的所提取的单词
#include<cctype>
#include<string>
#include<vector>
#include<iostream>
#include<cstdio>
#include<map>
#include<algorithm>
#define MAX 30
using namespace std;
vector<string> ans;
string Reg(const string& str)
{
int size = str.size();
string returnStr = str;
for (int i = 0;i != size;++i)
{
returnStr[i] = tolower(str[i]);
}
sort(returnStr.begin(), returnStr.end());
return returnStr;
}
void Print()
{
int size = ans.size();
for (int i = 0;i != size;++i)
{
cout << ans[i] << endl;
}
}
int main()
{
map<string, bool> refer;
vector<string> words;
string temp;
while (cin >> temp)
{
if (temp == "#")
{
break;
}
words.push_back(temp);
temp = Reg(temp);//规范化
if (!refer.count(temp))
{
refer[temp] = true;
}
else
{
refer[temp] = false;
}
}
int size = words.size();
for (int i = 0;i != size;++i)
{
if (refer[Reg(words[i])])
{
ans.push_back(words[i]);
}
}
sort(ans.begin(), ans.end());
Print();
return 0;
}