using namespace std;
int main()
{
string str;
while(cin>>str)
{
map<string,int>mymap;
for(int i=0;i<str.size();i++)
{
for(int j=1;j<=str.size()-i;j++)
{
string str2=str.substr(i,j);
cout<<str2<<endl;
if(mymap.find(str2)==mymap.end())
mymap[str2]=1;
else
{
mymap[str2]++;
}
}
}
for(auto it=mymap.begin();it!=mymap.end();it++)
{
if(1<it->second)
cout<<it->first<<" "<<it->second<<endl;
}
}
return 0;
}
子串计算
最新推荐文章于 2021-07-06 22:28:35 发布