占领无人区
查看原帖
占领无人区
1219814
wangshiran楼主2024/10/7 19:10

这道题为什么没人提交呀 给你们看一下我的全(W)对(A) 代码:

#include <iostream>
#include <string> 
using namespace std;
int main() {
    int N;
    string S, T;
    cin >> N >> S >> T;
    int count = 0;
    int lenT = T.length();    
    while (true) {
        size_t pos = S.find(T);
        if (pos == string::npos) {
            break;
        }
        S.erase(pos, lenT);
        count++;
    }
    cout << count << endl; 
    return 0;
}

为什么全(bu)对(dui)呀

2024/10/7 19:10
加载中...