STL algorithm count() demo

来源:互联网 发布:淘宝桔子运动是正品吗 编辑:程序博客网 时间:2024/05/16 12:22
#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;}

0 0