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 |
why wa??include<iostream.h> #include<string.h> const int MaxLen=1000; int l[MaxLen][MaxLen]; int LCS(char *A,char *B) { int m = strlen(A); int n = strlen(B); int i,j; for(i=0;i<=m;i++) { l[i][0]=0; } for(j=1;j<=n;j++) { l[0][j]=0; } for(i=1;i<=m;i++) { for(j=1;j<=n;j++) { if(A[i-1]==B[j-1]) l[i][j] = l[i-1][j-1]+1; else if(l[i][j-1]>l[i-1][j]) l[i][j] = l[i][j-1]; else l[i][j] = l[i-1][j]; } } return l[m][n]; } char a[MaxLen]; char b[MaxLen]; int main() { while(1) { cin>>a>>b; if(cin.eof()==1)break; cout<<LCS(a,b)<<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