upper用法:lower_bound(a+l,a+r,n);
前提 运用stl库函数且数列有序using namespace std;
algorithm 的 sort函数
lower_bound返回的是第一个大于或等于该m的地址
而upper则是返回大于m的地址
如图 我们就可以得到第一个大于等于6的地址。

#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
   
 int a[10]={
   3,5,6,0,2,1,3,4,5,6};
   sort(a,a+9);
  for(int i=0;i<=9;i++)
  printf("%d ",a[i]);
   int t=lower_bound(a,a+9,6)-a;
   printf("%d",t);
 }