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; }
相关文章推荐
- c++ standard library <numeric> accumulate demo
- c++ standard library fill_n demo
- [unresolved]《The C++ Standard Library》第37页 pair的几种初始化
- C++ Standard Library扩充建议...
- The C++ Standard Library 学习笔记(一)第6章
- Power up C++ with the Standard Template Library: Part I[翻译]
- Visual C++ Standard Library:next_permutation
- the boost graph library && Beyond the C++ Standard Library(boost中文版)
- Power up C++ with the Standard Template Library:Part II: Advanced Uses [翻译]
- The C++ Standard Library 学习笔记(一)第5章
- Beyond the C++ Standard Library: An Introduction to Boost -- Library 5.2 Usage
- Standard C++ Library Module User's Guide
- 《The C++ Standard Library》第42页 一段很难理解的话
- Effective Standard C++ Library: for_each() vs. transform()
- [unresolved]《The C++ Standard Library》第50页 该如何理解exception to the rule
- The C++ Standard Library Extensions: A Tutorial and Reference
- 《The C++ Standard Library》第39页 make_pair的作用
- 《The C++ Standard Library》第50页 关于传递auto_ptr的问题
- 个人翻译Beyond the C++ Standard Library
- Several Need-To-Know(assert/stdin/stdout/CString/Standard C++ Library)