题解 | #子串计算#

子串计算

https://www.nowcoder.com/practice/bcad754c91a54994be31a239996e7c11

#include <iostream>
#include <map>
using namespace std;

int main() {
    string str;
    while(cin >> str){
        map<string, int> number;
        for(int i = 0; i < str.size(); i ++)
            for(int j = 1; i + j <= str.size(); j ++){
                number[str.substr(i, j)] ++;
            }
        
        for(auto t : number){
            if(t.second > 1)
                cout << t.first << " " << t.second << endl;
        }
    }

    return 0;
}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

06-12 16:00
天津大学 Java
牛客30236098...:腾讯坏事做尽,终面挂是最破防的 上次被挂了后我连简历都不刷了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务