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> #define MAX(a,b) a>b?a:b int l[1000][1000]; int main() { char str1[1000],str2[1000]; int len1,len2,i,j; while(scanf("%s %s",str1,str2)!=EOF) { len1=strlen(str1); len2=strlen(str2); memset(l,0,sizeof(l)); for(i=0;i<=len1;i++) { for(j=0;j<=len2;j++) if(str1[i]==str2[j]) l[i+1][j+1]=l[i][j]+1; else l[i+1][j+1]=MAX(l[i+1][j],l[i][j+1]); } printf("%d\n",l[len1][len2]); } return 1; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator