#include <iostream>
#include <string>
#include <functional>
#include <vector>
#include <algorithm>
using namespace std;
//stl常见算法
/*
1.algorithm
2.numeric
3.functional
*/
//binary_search 查找相邻重复元素
void test01()
{
vector<int>v1;
for (int i = 0; i < 1000; i++)
{
v1.push_back(i);
}
bool ret = binary_search(v1.begin(), v1.end(),9);//返回布尔值,只能是有序容器才可以
if (!ret)
{
cout << "未找到!" << endl;
}
else
{
cout << "找到"<< endl;
}
}
int main()
{
test01();
system("pause");
return 0;
}
82 常用查找算法-binary_search
最新推荐文章于 2024-07-25 12:55:52 发布