#include "string"
using namespace std;
bool hasTheSubstr(string str,string substr)//determin if the str include the sub
string:substr
{
int length1=str.length();
int length2=substr.length();
if(length2>length1)return false;
int i=0;
while(i<=length1-length2)
{
string strs=str.substr(i,length2);
int j=0;
while(j<length2)
{
if(strs[j]!=substr[j])break;
j++;
}
if(j==length2)return true;
i++;
}
return false;
}
string findTheMaxLengthSubstring(string str)
{
int length=str.length();
string substr="";
string maxSubstr="";
int maxLength=0;
int i=0;
while(i<length)
{
int j=1;
while(j<=length-i)
{
substr=str.substr(i,j);
if(hasTheSubstr(str.substr(i+1),substr))//if substr is
in the remain substring of the oringinal string
{
if(maxLength<j){//if the substr which comply
with the rule now has a larger size,then set the maxSubstr to this substr
maxLength=j;
maxSubstr=substr;
}