#include <iostream>
#include <string>
#include <vector>
using namespace std;
class D{
//无重复字符的最长子串长度"2552546613271" "254613"是一个序列,最长子串是"61327"
public:int zichuan(){
int i,j,len;
int point=0; //标记切割点
int m=0; //最长子串长度
vector<string> v;
string s;
cout<<"输入一个字符串:"<<endl;
cin>>s;
len=s.size();
for(i=1;i<len;i++){
for(j=point;j<i;j++){
if(s[j]==s[i]){
v.push_back(s.substr(point,i-point));
m=i-point>m?i-point:m;
point=j+1; //更新point
break;//"2552546613271" point 0,2,3,7,9
}
}
}
if(len-point>1){
v.push_back(s.substr(point,len-point)); //末尾子串
m=len-point>m?len-point:m;
}
//cout<<v.size();
cout<<"打印所有子串:"<<endl;
for(int i=0;i<v.size();i++){
for(int j=0;j<v[i].size();j++){
cout<<v[i][j]<<" ";
}
cout<<endl;
}
cout<<"最长子串长度为:"<<m<<endl;
return 0;
}
};
int main(){
D d;
d.zichuan();
system("pause");
return 0;
}