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

Re:又刷水题一道!一次AC!

Posted by wenjiekong at 2012-07-14 09:55:25 on Problem 1458
In Reply To:又刷水题一道!一次AC! Posted by:130403199012042138 at 2010-08-29 10:01:53
#include<stdio.h>
#include<string.h>
main()
{
	int k,l,i,j,c[100][100],n;
	char a[100],b[100];
	while(scanf("%s%s",&a,&b)!=EOF)
	{
		
		k=strlen(a);
		l=strlen(b);
	    if(k>l)
			n=k;
		else 
			n=l;
		for(i=0;i<=n;i++)
		{
			c[0][i]=0;
			c[i][0]=0;
		}
		for(i=1;i<=k;i++)
			for(j=1;j<=l;j++)
			{
				if(a[i-1]==b[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[k][l]);
	}
}

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