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 |
Re:又刷水题一道!一次AC!In Reply To:又刷水题一道!一次AC! Posted by:130403199012042138 at 2010-08-29 10:01:53 #include<stdio.h> #include<string.h> main() { int k,l,i,j,c[100][100],n; char a[100],b[100]; while(scanf("%s%s",&a,&b)!=EOF) { k=strlen(a); l=strlen(b); if(k>l) n=k; else n=l; for(i=0;i<=n;i++) { c[0][i]=0; c[i][0]=0; } for(i=1;i<=k;i++) for(j=1;j<=l;j++) { if(a[i-1]==b[j-1]) c[i][j]=c[i-1][j-1]+1; else if(c[i-1][j]>c[i][j-1]) c[i][j]=c[i-1][j]; else c[i][j]=c[i][j-1]; } printf("%d\n",c[k][l]); } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator