upper_bound

upper_bound
1.
temp=upper_bound(a+1,a+n+1,x)-b;
temp表示在数组a中第一个大于x的位置

2.
bool cmp(int a,int b){
return a>b;
}
temp=upper_bound(a+1,a+n+1,x,cmp)-b;
temp表示在数组a中第一个小于x的位置

3.
bool cmp(int a,int b){
return a>=b;
}
temp=upper_bound(a+1,a+n+1,x,cmp)-b;
temp表示在数组a中第一个小于等于x的位置

原文地址:https://www.cnblogs.com/war1111/p/11277046.html