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<stdio.h> #include<string.h> int c[1000][1000]; char x[1000]; char y[1000]; int main() { int i,j,m,n; while(scanf("%s%s",x,y)!=EOF) { m=strlen(x); n=strlen(y); for(i=0;i<m;i++) c[i][0]=0; for(i=1;i<n;i++) c[0][i]=0; for(i=1;i<=m;i++) for(j=1;j<=n;j++) { if(x[i-1]==y[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[m][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