STL algorithm find() demo
2015-03-07 13:39
232 查看
#include <iostream> #include <algorithm> using namespace std; int main() { vector<int> ivec = { 1, 2, 10, 3, 4, 5 }; int target = 10; auto result = find(ivec.begin(), ivec.end(), target); if (result != ivec.end()) cout << "found at index " << result - ivec.begin() << endl; else cout << "not found" << endl; return 0; }
相关文章推荐
- (原創) 如何使用find_first_of() algorithm? (C/C++) (STL)
- STL find demo
- c++ stl algorithm: std::find, std::find_if
- c++ stl algorithm: std::find, std::find_if
- STL algorithm count demo
- STL algorithm accumulate vector<string> demo
- STL algorithm count() demo
- STL find_if demo
- (原創) 如何使用find() algorithm? (C/C++) (STL)
- c++ stl algorithm: std::find, std::find_if
- stl的find、find_if简单demo
- STL algorithm find
- STL algorithm find_if
- STL algorithm find_end
- How to learn C++ and find all STL Algorithm reference
- STL string demo
- C++_STL_algorithm(算法)
- STL insert() demo
- c++ STL ostream_iterator<> demo
- C++ STL系列(三)Algorithm