| ||||||||||
| 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 | |||||||||
Re:查来查去查了一年,还是不知道哪里错了!!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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator