hdu Word Amalgamation(map)

时间:2023-03-09 18:27:12
hdu   Word Amalgamation(map)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1113

找单词

 #include <iostream>
#include <string>
#include <map>
#include <algorithm>
using namespace std; map<string, string> str;
string s, t; int main()
{
while(cin >> s && s != "XXXXXX")
{
t = s;
sort(s.begin(), s.end());
str[t] = s;
}
while(cin >> s && s != "XXXXXX")
{
bool flag = ;
t = s;
sort(s.begin(), s.end());
for(map<string, string>::iterator it=str.begin(); it!=str.end(); ++it)
if(it->second == s)
{
cout << it->first << endl;
flag = ;
}
if(flag == )
cout << "NOT A VALID WORD\n";
cout << "******\n"; }
}