标签:
1 #include <cstdio> 2 #include <cmath> 3 #include <cstring> 4 #include <ctime> 5 #include <iostream> 6 #include <algorithm> 7 #include <set> 8 #include <vector> 9 #include <sstream> 10 #include <queue> 11 #include <typeinfo> 12 #include <fstream> 13 #include <map> 14 #include <stack> 15 using namespace std; 16 #define INF -100000 17 typedef long long ll; 18 const int maxn=110; 19 string words,tmp,query; 20 map<string,string> ans; 21 int main() 22 { 23 // freopen("in.txt","r",stdin); 24 // freopen("out.txt","w",stdout); 25 while(cin>>words){ 26 if(words=="XXXXXX") break; 27 tmp=words; 28 sort(words.begin(),words.end()); 29 ans[tmp]=words; 30 } 31 while(cin>>query){ 32 if(query=="XXXXXX") break; 33 int flag=0; 34 sort(query.begin(),query.end()); 35 for(map<string,string>::iterator it=ans.begin();it!=ans.end();it++) 36 if(it->second==query){ 37 cout<<it->first<<endl; 38 flag=1; 39 } 40 if(!flag) printf("NOT A VALID WORD\n"); 41 printf("******\n"); 42 } 43 return 0; 44 }
标签:
原文地址:http://www.cnblogs.com/RRirring/p/4718701.html