#include <iostream>
#include <cstdio>
#include <map>
using namespace std;
int main(){
string str;
while(cin>>str){
map<string,int> ma;
for(int i = 1;i <= str.size();i++){
for(int j = 0;j < i;j++ ){
string key = str.substr(j,i-j);//获取子串
ma[key] ++;
}
}
map<string,int>::iterator it;
for(it = ma.begin(); it != ma.end();it++){
// if(it->second > 1){
cout <<it->first <<" " << it->second<< endl;
// }
}
}
return 0;
}
获取string所有子串 map迭代
最新推荐文章于 2025-02-18 14:26:10 发布

2040

被折叠的 条评论
为什么被折叠?



