#include<iostream>
#include<string>
#include<map>
 
using namespace std;
 
int main() {
    string str;
    while (cin >> str) {
        map<string, int> mp;
        for (int i = 0; i < str.length(); i++) {
            for (int len = 1; len <= str.length() - i; len++) {
                string tmp = str.substr(i, len);
                cout<<"tmp:"<<tmp<<endl;
                mp[tmp]++;
                cout<<"map:"<<mp[tmp]<<endl;
            }
        }
        map<string, int>::iterator it;
        for (it = mp.begin(); it != mp.end(); it++) {
            if (it->second > 1)
                cout << it->first << " " << it->second << endl;
        }
    }
    return 0;
}

 

https://www.nowcoder.com/practice/bcad754c91a54994be31a239996e7c11?tpId=40&tqId=21399&tPage=1&rp=1&ru=/ta/kaoyan&qru=/ta/kaoyan/question-ranking

西安电子大学计算机考研复试机试(2019)+ 牛客网(划分字串+map应用)

相关文章:

  • 2021-04-23
  • 2021-12-18
  • 2021-04-01
  • 2021-05-18
  • 2021-08-03
  • 2021-06-04
  • 2021-12-18
  • 2021-12-18
猜你喜欢
  • 2021-06-27
  • 2021-12-18
  • 2021-12-18
  • 2021-12-18
  • 2022-02-23
  • 2021-12-18
  • 2021-12-28
相关资源
相似解决方案