#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
vector<string> svec = { "hello", "world", "hello", "sun" };
string target = "hello";
auto cnt = count(svec.begin(), svec.end(), target);
cout << "there are " << cnt << " " << target << endl;
return 0;
}
STL algorithm count() demo
最新推荐文章于 2022-03-02 20:37:02 发布