首页 > 编程 > C++ > 正文

C++ STL

2019-11-10 22:48:47
字体:
来源:转载
供稿:网友

格式:lower_bound(str,str+n,x)-str.

#include <cstdio>#include <algorithm>//必须包含的头文件 using namespace std;int main(){ int point[10] = {1,3,7,7,9}; int tmp = upper_bound(point, point + 5, 7) - point;//按从小到大,7最多能插入数组point的哪个位置 PRintf("%d/n",tmp); tmp = lower_bound(point, point + 5, 7) - point;////按从小到大,7最少能插入数组point的哪个位置 printf("%d/n",tmp); return 0;}

output:

2

4

 


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表

图片精选