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:数组 201 即可,大概是200 个字符长度

Posted by 13408229 at 2014-08-17 11:06:49 on Problem 1458
In Reply To:数组 201 即可,大概是200 个字符长度 Posted by:13408229 at 2014-08-17 11:04:41
#include<iostream>
#include<string>
using namespace std;
string x,y;
short int a1,a2,ans,bz[201][201];
int main()
{
    while (cin>>x>>y)
    {
        int i,j;
        memset(bz,-1,sizeof(bz));
        a1=x.length();
        a2=y.length();
        for(i=0;i<=a1;i++)bz[i][0]=0;
        for(i=0;i<=a2;i++)bz[0][i]=0;
        for(i=0;i<a1;i++)
        for(j=0;j<a2;j++)
        {
        	if(x[i]==y[j])bz[i+1][j+1]=bz[i][j]+1;
        	else bz[i+1][j+1]=max(bz[i][j+1],bz[i+1][j]);
        }
        cout<<bz[a1][a2]<<endl;
    }
}

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