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:查来查去查了一年,还是不知道哪里错了!!

Posted by nenu10_wangd at 2010-08-25 10:00:20 on Problem 1458
In Reply To:查来查去查了一年,还是不知道哪里错了!! Posted by:Algor at 2010-04-15 22:05:38
> #include<iostream>
> using namespace std;
> #define N 2000
> char rec[N][N],str1[N],str2[N];
> int LCS()
> {
> 	int l1,l2,i,j;
> 	l1=strlen(str1);
> 	l2=strlen(str2);
> 	memset(rec,0,sizeof(rec));
> 	for(i=1;i<=l1;i++)
> 	{
> 		for(j=1;j<=l2;j++){
> 			if(str1[i-1]==str2[j-1])
> 				rec[i][j]=rec[i-1][j-1]+1;
> 			else if(rec[i][j-1]<rec[i-1][j])
> 				rec[i][j]=rec[i-1][j];
> 			else rec[i][j]=rec[i][j-1];
> 		}
> 	}
> 	return rec[l1][l2];
> }
> int main()
> {
> 	while(scanf("%s %s",str1,str2)!=EOF)
> 		printf("%d\n",LCS());
> 	return 0;
> }
/////这位大虾数据类型错了,rec[N][N] 应该为int 型

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