UVA 850
#include<iostream> #include<cstring> #include<cstdio> #include<cctype> using namespace std; char a[100][100]; char s[]={"the quick brown fox jumps over the lazy dog"}; char change[100]; int ifFind(char a[]) { int i; int vis[100]; int ok=1; memset(vis,0,sizeof(vis)); for(i=0;i<strlen(a);i++) { if(isalpha(a[i])) { int temp=a[i]-'a'; if(!vis[temp]&&isalpha(s[i])) { vis[temp]=1; change[temp]=s[i]; } else { if(change[temp]!=s[i]) { ok=0; break; } } } } if(ok)return 1; else return 0; } int main() { int n; cin>>n; cin.ignore(); while(n--) { cout<<endl; int flag1=0; char temp[200]; while(gets(temp)) { if(strcmp(temp,"")==0) break; else { strcpy(a[flag1],temp); flag1++; } } int flag2=-1,j,k; for(j=0;j<flag1;j++) { if(ifFind(a[j])) { flag2=j; break; } } if(flag2==-1) { cout<<"No solution."<<endl; } else { char *p; for(j=0;j<flag1;j++) { for(k=0;k<strlen(a[j]);k++) { p=strchr(a[flag2],a[j][k]); cout<<s[p-a[flag2]]; } cout<<endl; } } } return 0; }