您的位置:首页 > 编程语言 > C语言/C++

c++ standard library algorithm count demo

2015-02-01 19:09 531 查看
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main()
{
int arr[] = {1, 2, 101, 20, 101, 101, 200};
size_t array_size = sizeof(arr) / sizeof(arr[0]);
vector<int> ivec(arr, arr + array_size);

const int search_value = 101;
vector<int>::size_type cnt = count(ivec.begin(), ivec.end(), search_value);
cout << cnt << endl;

getchar();
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: