您的位置:首页 > 编程语言 > Go语言

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;
}


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