#include <iostream>
#include <stdlib.h>
#include <map>
using namespace std;
void func()
{
string s;
while(cin>>s)
{
map<string,int> ma;
for(int i=0;i<s.size();i++)
{
for(int j=1;j+i<=s.size();j++)
{
ma[s.substr(i,j)]++;
}
}
map<string,int>::iterator it;
for(it=ma.begin();it!=ma.end();it++)
{
if(it->second>1)
cout<<it->first<<" "<<it->second<<endl;
}
}
}
int main(int argc, char *argv[])
{
//printf("Hello, world\n");
func();
return 0;
}
-
题目描述:
-
给出一个01字符串(长度不超过100),求其每一个子串出现的次数。
-
输入:
-
输入包含多行,每行一个字符串。
-
输出:
-
对每个字符串,输出它所有出现次数在1次以上的子串和这个子串出现的次数,输出按字典序排序。
-
样例输入:
-
10101
-
样例输出:
-
0 2 01 2 1 3 10 2 101 2