lower_bound() && upper_bound()

1,lower_bound
用法:

a[] 中查询k的位置

找的是大于等于他的第一个数,返回值为对应下标
x=lower_bound(a+1,a+n+1,k)-a;

2,upper_bound
用法:

a[] 中查询k的位置

找的是大于他的第一个数,返回值为对应下标
x=upper_bound(a+1,a+n+1,k)-a;

原文地址:https://www.cnblogs.com/adelalove/p/8492483.html