题解 | 子串计算
子串计算
https://www.nowcoder.com/practice/bcad754c91a54994be31a239996e7c11
#include <iostream>
#include<map>
using namespace std;
map<string, int>countt;
int main() {
string str;
while (cin >> str) { // 注意 while 处理多个 case
for (int i = 1; i <= str.size(); i++) {
for (int j = 0; j + i <= str.size(); j++) {
/*cout << str.substr(j, i) << ' ';*/
countt[str.substr(j, i)]++;
}
}
for (auto item : countt) {
if(item.second>1)
cout << item.first << ' ' << item.second << endl;
}
}
}
// 64 位输出请用 printf("%lld")


