| ||||||||||
| 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 | |||||||||
common#include <stdio.h>
#include <string.h>
#define MAX 1000
char zly1[MAX],zly2[MAX];
int zlyMaxLen[MAX][MAX];
void main()
{
while(scanf("%s%s",zly1+1,zly2+1)!=EOF)
{
int L1,L2;
L1=strlen(zly1+1);
L2=strlen(zly2+1);
int i,j;
for(i=0;i<L1;i++)
{
zlyMaxLen[i][0]=0;
}
for(j=0;j<L1;j++)
{
zlyMaxLen[0][j]=0;
}
for(i=1;i<=L1;i++)
{
for(j=1;j<=L2;j++)
{
if(zly1[i]==zly2[j])
zlyMaxLen[i][j]=1+zlyMaxLen[i-1][j-1];
else
zlyMaxLen[i][j]=zlyMaxLen[i-1][j]>zlyMaxLen[i][j-1]?zlyMaxLen[i-1][j]:zlyMaxLen[i][j-1];
}
}
printf("%d\n",zlyMaxLen[L1][L2]);
}
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator