Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
ac#include<stdio.h> #include<algorithm> #include<string.h> using namespace std; int main() { int l,i,l1,flag; char s[1000][1000],s1[1000],s2[1000][1000],s3[1000]; i=0; while(1) { scanf("%s",s[i]); if(strcmp(s[i],"XXXXXX")==0) break; i++; } for(int j=0;j<i;j++) for(int k=j+1;k<i;k++) { if(strcmp(s[j],s[k])>0) { strcpy(s3,s[j]); strcpy(s[j],s[k]); strcpy(s[k],s3); } } for(int j=0;j<i;j++) { strcpy(s2[j],s[j]); l=strlen(s[j]); sort(s[j],s[j]+l); } while(1) { scanf("%s",s1); if(strcmp(s1,"XXXXXX")==0) break; flag=0; l1=strlen(s1); sort(s1,s1+l1); for(int j=0;j<i;j++) { if(strcmp(s1,s[j])==0) { printf("%s\n",s2[j]); flag++; } } if(flag!=0) printf("******\n"); if(flag==0) printf("NOT A VALID WORD\n******\n"); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator