#include <string>
#include <iostream>
using namespace std;
int main()
{
string a;
string b;
cin>>a;
cin>>b;
int count = 0;
int Max = 0;
int start1,start2;
for(int i=0; i<a.size(); i++)
{
for(int j=0; j<b.size(); j++)
{
start1=i;
start2=j;
while(a[start1]==b[start2] && start1<a.size() && start2<b.size())
{
start1++;
start2++;
count++;
}
if(count>Max)
{
Max=count;
}
count=0;
}
}
cout<<Max<<endl;
return 0;
}
最长公共串
最新推荐文章于 2022-09-26 21:44:31 发布