#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;
}
西安电子大学计算机考研复试机试(2019)+ 牛客网(划分字串+map应用)
最新推荐文章于 2024-06-10 00:17:25 发布