统计字符串A 在字符串B出现的个数

来源:互联网 发布:内乡王登科网络诈骗 编辑:程序博客网 时间:2024/05/29 13:24
<span style="font-size:14px;">#include <iostream>#include <string>#include <algorithm>using namespace std;int main(){    int n;    string str1;    string str2;    cin >> n;    while (n--) {        cin >> str1 >> str2;        size_t found = 0;        int iTime = 0;        while ((found = str2.find(str1,found)) != string::npos) {            iTime++;            found++;        }        cout << iTime << endl;    }    return 0;}</span>
统计str1 在str2里出现的总次数
0 0
原创粉丝点击