题解 | #子串计算#
子串计算
https://www.nowcoder.com/practice/bcad754c91a54994be31a239996e7c11
#include<iostream> #include<map> #include<string> using namespace std; map<string,int>mp; int main(void) { string str; cin >> str; int len = str.size(); for(int i = 0;i < len;i++) { for(int j = 1;j <= len - i;j++) { string t = str.substr(i,j); mp[t]++; } } for(auto s : mp) { if(s.second > 1)cout << s.first << " " <<s.second << endl; } return 0; }