#include <bits/stdc++.h>
using namespace std;
int a[10]={10,10,10,10,50,60,70,80,90,100};
int main(void)
{
int i=11;//当元素不存在时,lower_bound和upper_bound返回的值是一样的,就比较尬
cout <<lower_bound(a,a+10,i)-a<<endl;
cout <<upper_bound(a,a+10,i)-a<<endl;
return 0;
}
C++-upper_bound和lower_bound函数坑点总结
最新推荐文章于 2024-04-09 16:12:08 发布