#include <algorithm> iterator find( iterator start, iterator end, const TYPE& val ); 例一,在容器中查找: int num_to_find = 3; vector<int> v1; for( int i = 0; i < 10; i++ ) { v1.push_back(i); } vector<int>::iterator result; result = find( v1.begin(), v1.end(), num_to_find ); if( result == v1.end() ) { cout << "Did not find any element matching " << num_to_find << endl; } else { cout << "Found a matching element: " << *result << endl; }
c++ find 用法
最新推荐文章于 2024-05-31 11:24:32 发布