题解 | #子串计算#
子串计算
https://www.nowcoder.com/practice/bcad754c91a54994be31a239996e7c11
#include <iostream> #include <string> #include <cstdio> #include <map> using namespace std; const int MAX=101; int main() { string s; map<string,int>myMap; map<string,int>::iterator it; while(cin>>s){ for(int i=0;i<s.size();i++){ for(int j=1;j<=s.size()-i;j++){ myMap[s.substr(i,j)]++; } } for(it=myMap.begin();it!=myMap.end();it++){ if(it->second>1){ cout <<it->first<<" "<<it->second <<endl; } } } return 0; } // 64 位输出请用 printf("%lld")