#include<iostream>
#include<string>
using namespace std;
int main()
{
string str;
getline(cin, str);
int length = str.size();
int maxlen= 1;
int curlen = 0;
int start = 0;
int startlen = 0;
for (int i = 1; i < length; i++)
{
if (str[i] == str[i - 1])
{
curlen++;
if (curlen > maxlen)
{
maxlen = curlen;
startlen = start;
}
}
else
{
curlen = 0;
start = i;
}
}
cout << startlen << endl;
cout << startlen+maxlen << endl;
for (int i = startlen; i <= startlen + maxlen; i++)
{
cout << str[i];
}
system("pause");
return 0;
}
最长重复子串
最新推荐文章于 2024-11-04 19:24:37 发布