#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
using namespace std;
int main()
{
int a[]={4,10,11,30,30,69,70,96,100};
int a2[]={30,69,70};
int a3[]={30,50,70};
vector<int> vec(a,a+9);
vector<int> vec2(a2,a2+3);
vector<int> vec3(a3,a3+3);
int binary1=binary_search(vec.begin(),vec.end(),4);
cout<<"在数组中查找元素4,结果为:"<<binary1<<endl;//查找成功,返回1
int binary2=binary_search(vec.begin(),vec.end(),40);
cout<<"在数组中查找元素40,结果为:"<<binary2<<endl;//查找失败,返回0
int lower1=lower_bound(vec.begin(),vec.end(),10)-vec.begin();
cout<<"在数组中查找第一个大于等于10的元素位置,结果为:"<<lower1<<endl;//返回1
int lower2=lower_bound(vec.begin(),vec.end(),101)-vec.begin();
cout<<"在数组中查找第一个大于等于101的元素位置,结果为:"<<lower2<<endl;//返回9
int upper1=upper_bound(vec.begin(),vec.end(),10)-vec.begin();
cout<<"在数组中查找第一个大于10的元素位置,结果为:"<<upper1<<endl;//返回2
int upper2=upper_bound(vec.begin(),vec.end(),101)-vec.begin();
cout<<"在数组中查找第一个大于101的元素位置,结果为:"<<upper2<<endl;//返回9
auto bounds=equal_range(vec.begin(),vec.end(),30);
int min=bounds.first-vec.begin();
int max=bounds.second-vec.begin();
cout<<"在数组中查找到的30所在的范围为"<<"["<<min<<","<<max<<")"<<endl;//返回[3,5)
auto bounds2=equal_range(vec.begin(),vec.end(),100);
min=bounds2.first-vec.begin();
max=bounds2.second-vec.begin();
cout<<"在数组中查找到的100所在的范围为"<<"["<<min<<","<<max<<")"<<endl;//返回[8,9)
int include1=includes(vec.begin(),vec.end(),vec2.begin(),vec2.end());
cout<<"在vec1中查找vec2,结果为:"<<include1<<endl; //查找成功,返回1
int include2=includes(vec.begin(),vec.end(),vec3.begin(),vec3.end());
cout<<"在vec1中查找vec3,结果为:"<<include2<<endl; //查找失败,返回0
}