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 heliwen at 2008-12-20 20:44:28 on Problem 1458
#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:
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