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 |
贴个代码,水过#include <iostream> using namespace std; char a[10001][20],t[20]; int s[10001],slen,alen=0,r; int cmp(char a[],char b[]){ int m=0,n=0,min,max,cnt=0,p=0; while(a[m++]); while(b[n++]); if(m==n){ while(p!=m)if(a[p]==b[p++])cnt++; if(cnt==m)return 0; if(cnt==m-1)return 1; return 2; } min = m>n?n:m; max = m+n-min; if(max-min>1)return 2; char *mins = m>n?b:a; char *maxs = m>n?a:b; for(int i=0;i<min;i++) while(maxs[p++]!=mins[i]) if(p>=max)return 2; return 1; } int main() { while(cin>>a[alen]){ if(a[alen][0]=='#')break; alen++; } while(1){ l:cin>>t; if(t[0]=='#')break; slen = 0; for(int i=0;i<alen;i++){ r = cmp(t,a[i]); if(!r){ cout<<t<<" is correct"<<endl; goto l; } if(r==1)s[slen++] = i; } cout<<t<<":"; if(slen)for(int i=0;i<slen;i++)cout<<' '<<a[s[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