代码

#include<iostream>
#include<algorithm>
using namespace std; int main(void) { float cdf[] = { 0.13,0.23,0.33,0.43,0.53 };
// 从数组的begin位置到end位置第一个大于或等于num的数字,不存在则返回end
cout << *(lower_bound(cdf, cdf + , 0.32)) << endl;
cout << *(lower_bound(cdf, cdf + , 0.33)) << endl;
cout << *(lower_bound(cdf, cdf + , 0.34)) << endl;
cout << *(lower_bound(cdf, cdf + , 0.43)) << endl;
cout << *(lower_bound(cdf, cdf + , 0.44)) << endl; return ;
}

输出

0.33
0.33
0.43
0.43
0.53

C++ lower_bound的更多相关文章

  1. STL源码学习----lower_bound和upper_bound算法

    转自:http://www.cnblogs.com/cobbliu/archive/2012/05/21/2512249.html 先贴一下自己的二分代码: #include <cstdio&g ...

  2. 【刷题记录】 && 【算法杂谈】折半枚举与upper_bound 和 lower_bound

    [什么是upper_bound 和 lower_bound] 简单来说lower_bound就是你给他一个非递减数列[first,last)和x,它给你返回非递减序列[first, last)中的第一 ...

  3. STL之lower_bound和upper_bound

    ForwardIter lower_bound(ForwardIter first, ForwardIter last,const _Tp& val)算法返回一个非递减序列[first, la ...

  4. UVA 10474 大理石在哪 lower_bound

    题意:找输入的数在排完序之后的位置. 主要是lower_bound 函数的使用.它的作用是查找大于或者等于x的第一个位置. #include<cstdio> #include<alg ...

  5. [ACM] hdu 1025 Constructing Roads In JGShining's Kingdom (最长递增子序列,lower_bound使用)

    Constructing Roads In JGShining's Kingdom Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65 ...

  6. LeetCode:Search Insert Position,Search for a Range (二分查找,lower_bound,upper_bound)

    Search Insert Position Given a sorted array and a target value, return the index if the target is fo ...

  7. [STL] lower_bound和upper_bound

    STL中的每个算法都非常精妙, ForwardIter lower_bound(ForwardIter first, ForwardIter last,const _Tp& val)算法返回一 ...

  8. STL lower_bound upper_bound binary-search

    STL中的二分查找——lower_bound .upper_bound .binary_search 二分查找很简单,原理就不说了.STL中关于二分查找的函数有三个lower_bound .upper ...

  9. vector的插入、lower_bound、upper_bound、equal_range实例

    对于这几个函数的一些实例以便于理解: #include <cstdlib> #include <cstdio> #include <cstring> #includ ...

  10. STL中的lower_bound和upper_bound的理解

    STL迭代器表述范围的时候,习惯用[a, b),所以lower_bound表示的是第一个不小于给定元素的位置 upper_bound表示的是第一个大于给定元素的位置. 譬如,值val在容器内的时候,从 ...

随机推荐

  1. trigger添加及表达式

    创建触发器 点击Configuration(配置) → Hosts(主机) 点击hosts(主机)相关行的trigger 点击右上角的创建触发器(create trigger) name : 触发器名 ...

  2. mysql和oracle的语法差异(网络收集)

    oracle没有offet,limit,在mysql中我们用它们来控制显示的行数,最多的是分页了.oracle要分页的话,要换成rownum. oracle建表时,没有auto_increment,所 ...

  3. 【SPOJ2371】LIS2

    题目大意:求二维最长上升子序列的长度. 题解: 可以看出,这个问题等价于三维偏序问题. 不过在进行分治的时候要注意,由于 dp 转移是有顺序的,因此只能先处理左半部分,再处理左半部分对右边的贡献,最后 ...

  4. Spring资源

    资源 官网:http://spring.io 文档:https://docs.spring.io/spring/docs/current/spring-framework-reference/.htt ...

  5. Centos7——docker入门(笔记)

    docker 入门(笔记) 一.Docker是什么? 官方原话: Docker provides a way to run applications securely isolated in a co ...

  6. 【JZOJ5430】【NOIP2017提高A组集训10.27】图

    题目 有一个n个点的无向图,给出m条边,每条边的信息形如\(<x,y,c,r>\) 给出q组询问形如\(<u,v,l,r>\) 接下来解释询问以及边的意义 询问表示,一开始你在 ...

  7. 测试网站接口,nginx篇

    nginx是反向代理,怎么通过nginx反向代理要测试接口的线上网站呢. 这里自我提供了一个方法,仅供参考!建议不要用于刷接口等非常规的用途,后果会很严重. 首先 用node express创建一个项 ...

  8. 18-Node.js学习笔记-Express-请求处理-构建模块化路由

    构建模块化路由 const express = require('express') //创建路由对象 const home = express.Router(); //将路由和请求路径进行匹配 ap ...

  9. pika 与 rabbitMQ 阻塞连接

    之前只是用celery, 这次用一下pika 参考rabbitMQ官网的python版,https://www.rabbitmq.com/tutorials/tutorial-one-python.h ...

  10. poj 3623(贪心)

    Best Cow Line, Gold Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 6038   Accepted: 20 ...