文章
43
粉丝
180
获赞
21
访问
196.0k
#include <iostream>
#include <cstring>
using namespace std;
string s1, s2;
int main()
{
while (cin >> s1 >> s2)
{
int res = 0, mxi = 0;
for (int i = 0; i < s1.size(); i ++ )
for (int j = 0; j < s2.size(); j ++ )
{
int cnt = 0, k = i, t = j;
while (k < s1.size() && s1[k ++] == s2[t ++]) cnt ++;
if (cnt >= res) res = cnt, mxi = i;
}
cout << res << endl << s1.substr(mxi, res) << endl;
}
return 0;
}
登录后发布评论
暂无评论,来抢沙发