题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1113
找单词
1 #include <iostream> 2 #include <string> 3 #include <map> 4 #include <algorithm> 5 using namespace std; 6 7 map<string, string> str; 8 string s, t; 9 10 int main() 11 { 12 while(cin >> s && s != "XXXXXX") 13 { 14 t = s; 15 sort(s.begin(), s.end()); 16 str[t] = s; 17 } 18 while(cin >> s && s != "XXXXXX") 19 { 20 bool flag = 0; 21 t = s; 22 sort(s.begin(), s.end()); 23 for(map<string, string>::iterator it=str.begin(); it!=str.end(); ++it) 24 if(it->second == s) 25 { 26 cout << it->first << endl; 27 flag = 1; 28 } 29 if(flag == 0) 30 cout << "NOT A VALID WORD "; 31 cout << "****** "; 32 33 } 34 }