1.lower_bound(begin,end,x)

返回第一个>=x的位置,找不到return .end()

2.upper_bound (begin,end,x)

返回第一个>x的位置,找不到return .end()

减掉begin得到下标

vector版

#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;
vector<int>a;
int b[];
int main(){ a.push_back();
a.push_back();
a.push_back();
a.push_back();
int p=lower_bound(a.begin(),a.end(),)-a.begin();
int q=lower_bound(a.begin(),a.end(),)-a.begin();
printf("%d %d\n",p,q);// 0 2 p=upper_bound(a.begin(),a.end(),)-a.begin();
q=upper_bound(a.begin(),a.end(),)-a.begin();
int r=upper_bound(a.begin(),a.end(),)-a.begin();
printf("%d %d %d\n",p,q,r);// 2 3 4 return ;
}

数组版

#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;
vector<int>a;
int b[]={,,,};
int main(){
int p=lower_bound(b,b+,)-b;
int q=lower_bound(b,b+,)-b;
printf("%d %d\n",p,q);// 0 2 p=upper_bound(b,b+,)-b;
q=upper_bound(b,b+,)-b;
int r=upper_bound(b,b+,)-b;
printf("%d %d %d\n",p,q,r);// 2 3 4 return ;
}

set (直接返回值)

#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
using namespace std;
multiset<int>s;
int main(){
s.insert();
s.insert();
s.insert();
s.insert();
set<int>::iterator p=s.lower_bound();
set<int>::iterator q=s.lower_bound();
printf("%d %d\n",*p,*q);// 1 2
return ;
}

最新文章

  1. spring自动扫描、DispatcherServlet初始化流程、spring控制器Controller 过程剖析
  2. CoreData 数据模型的版本控制
  3. [ASE]sprint2 总结 &amp; sprint3计划
  4. angularjs 指令—— 绑定策略(@、=、&amp;)
  5. .Net事件管道详解图
  6. Web Service中的几个重要术语
  7. 熊猫TV提示“您的账号存在被盗风险,请在网站上登录解锁”
  8. [android警告] AndroidManifest.xml警告 Should explicitly set android:allowBackup to true or false
  9. 实现 kindle 原生系统、多看系弹出注释的通用写法
  10. 手动将MySQL服务安装到windows中
  11. HW2.5
  12. java打jar包 命令行cmd在当前路径打jar包
  13. 引用 IP电话的原理结构及其关键技术
  14. android 巧用资源文件(不断积累)
  15. linux虚拟机网络配制方法及遇到问题的解决方法
  16. iptables配置详解
  17. python之 正则表达式
  18. AsyncTask(异步任务)讲解-android的学习之旅(四十六)
  19. LeetCode(34)-Palindrome Number
  20. linux 下的OpenGL的安装配置

热门文章

  1. 饿了么 &lt;el-input&gt;&lt;/el-input&gt;输入框获取与失去焦点事件
  2. JMeter 阶梯式加压测试插件 Concurrency Thread Group
  3. Linux系统之-常用命令及技巧
  4. centos svn 安装
  5. 使用js在页面上新建文件夹
  6. Notepad++ 连接 FTP 实现编辑 Linux文件
  7. 2018 ICPC Asia Singapore Regional A. Largest Triangle (计算几何)
  8. python学习笔记:python操作redis
  9. 力扣算法——135Candy【H】
  10. 获取项目根目录(非tomact)