主要是2个东西:lower_bound和upper_bound的用法
1)lower_bound
int p=lower_bound(a,a+n,x)-a;//在已排数组a中寻找x的位置
易知其含义:是寻找大于或等于x的第一个位置
int a[7]={12,5,3,5,98,21,7};
sort(a,a+7);
int *p=lower_bound(a,a+7,5);
cout<<*p<<","<<p-a<<endl;//输出=>5,1
2)upper_bound
其含义:寻找大于x的第一个位置
int a[7]={12,5,3,5,98,21,7};
sort(a,a+7);
int *p=upper_bound(a,a+7,5);
cout<<*p<<","<<p-a<<endl;//输出=>7,3
ps:如果找的数不在其数组范围内,那么输出排序后的最后一个数
在上面的基础上
cout<<*upper_bound(a,a+7,13)<<endl;//=>21