寻找子串时,采用暴力搜索
//该题处理子串时采用暴力搜索
#include <iostream>
#include <string>
#include <map>
using namespace std;
int main()
{
map<string, int> mp; //sub string ---> number
string s;
cin >> s;
for (int i = 0; i < s.size(); i++) {
for (int j = i+1; j <= s.size(); j++) {
string key = s.substr(i, j-i);
mp[key]++;
}
}
for (auto it = mp.begin(); it != mp.end(); it++) {
if (it->second > 1) {
cout << it->first << " " << it->second << endl;
}
}
return 0;
}