Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

注意数组的大小!!!!

Posted by chenxuan123456789 at 2012-07-28 10:12:01 on Problem 1458
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator