触宝内推-substring-c++
作者:
Jacinth | 来源:发表于
2017-09-06 00:22 被阅读0次
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <map>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <unordered_map>
using namespace std;
int main()
{
int n;
while (cin >> n)
{
vector<string> strLib;
for (int i = 0; i < n; ++i)
{
string str;
cin >> str;
strLib.push_back(str);//字符串之后插入一个字符
}
int m;
cin >> m;
for (int i = 0; i < m; ++i)
{
string query;
cin >> query;
int cnt = 0;
for (auto str : strLib)
{
if (str.find(query) != string::npos)//查找字符串str是否包含子串query
cnt++;
}
cout << cnt << endl;
}
}
return 0;
}
push_back使用方法
C++中string.find()函数与string::npos
本文标题:触宝内推-substring-c++
本文链接:https://www.haomeiwen.com/subject/ucfmjxtx.html
网友评论