#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;
}
STL algorithm find() demo
最新推荐文章于 2024-04-02 19:09:01 发布