Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 3541 Accepted Submission(s): 1742
#include<iostream> #include<cstdio> #include<cstring> #include<stdlib.h> #include<algorithm> #include<cmath> #include<string> #include<map> using namespace std; map<string,string>m; void input() { string a,b; while(1) { cin>>a; if(a=="XXXXXX") break; b=a; sort(a.begin(),a.end()); m[b]=a; } } void deal() { string a; while(1) { cin>>a; if(a=="XXXXXX") break; sort(a.begin(),a.end()); map<string,string>::iterator it; int flag=0; for(it=m.begin(); it!=m.end(); it++) { if(it->second==a) { flag=1; cout<<it->first<<endl; } } if(!flag) printf("NOT A VALID WORD\n"); cout<<"******"<<endl; } } int main() { input(); deal(); return 0; }
原文:http://www.cnblogs.com/jasonlixuetao/p/5914523.html