#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
//查找相邻重复元素 adjacent_find
void test01()
{
vector<int>v;
v.push_back(10);
v.push_back(30);
v.push_back(20);
v.push_back(10);
v.push_back(40);
v.push_back(40);
vector<int>::iterator pos = adjacent_find(v.begin(), v.end());
if (pos == v.end())
{
cout << "未找到!" << endl;
}
else
{
cout << "找到了! 元素为: " << *pos << endl;
}
}
int main()
{
test01();
system("pause");
return 0;
}
03_常用查找算法_adjacent_find
最新推荐文章于 2024-02-19 16:38:10 发布