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<iostream> #include<string.h> #include<algorithm> using namespace std; int main() { int n=0,m=0,i,j,h,g,a,w,r; char s[10001][16],b[50][16]; while(scanf("%s",s[n])!=EOF) { if(strcmp(s[n],"#")==0) break; n++; } while(scanf("%s",b[m])!=EOF) { if(strcmp(b[m],"#")==0) break; m++; } for(i=0;i<m;i++) { int flag=1,z=0; for( w=0,r=0;w<n;w++) { if(strcmp(b[i],s[w])==0) { cout<<b[i]<<" "<<"is correct"<<endl; r=1; break; } } if(r==1) continue; for(j=0;j<n;j++) { if(strlen(b[i])==strlen(s[j])) { int x=0; for(int g=0;g<strlen(s[j]);g++) { if(s[j][g]!=b[i][g]) x++; } if(x==1) { z=1; if(flag==1) cout<<b[i]<<":"; cout<<" "; cout<<s[j]; flag++; } } else if(strlen(b[i])==strlen(s[j])+1) { for( g=0,h=0,a=0;g<strlen(b[i]);) { if(b[i][g]==s[j][a]) a++,g++; else h++,g++; } if(h==1) { z=1; if(flag==1) cout<<b[i]<<":"; cout<<" "; cout<<s[j]; flag++; } } else if(strlen(b[i])==strlen(s[j])-1) { for( g=0,h=0,a=0;g<strlen(s[j]);) { if(b[i][a]==s[j][g]) a++,g++; else h++,g++; } if(h==1) { z=1; if(flag==1) cout<<b[i]<<":"; cout<<" "; cout<<s[j]; flag++; } } } if(z==0) { cout<<b[i]<<":"; } cout<<endl; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator