set的lower_bound是什么鬼东西啊

学术版

有问题吗
by hpbl @ 2018-12-22 16:39:37


1000是第一个比500大与等于的
by tоurist @ 2018-12-22 16:40:15


@[lhy930](/space/show?uid=60899) 查比500小的为什么出1000啊不应该是100?
by a2956331800 @ 2018-12-22 16:40:39


@[a2956331800](/space/show?uid=9517) ```lower_bound```查找的是第一个大于等于这个数的数
by hpbl @ 2018-12-22 16:41:11


@[a2956331800](/space/show?uid=9517) 楼上正解
by Zenurik @ 2018-12-22 16:41:51


thx 真是绝了调了半个多小时了
by a2956331800 @ 2018-12-22 16:42:56


那有没有查$\le$的函数啊
by a2956331800 @ 2018-12-22 16:43:23


cplusplus.com?
by smallfang @ 2018-12-22 16:50:42


@[a2956331800](/space/show?uid=9517) ~~手写~~
by 引领天下 @ 2018-12-22 16:51:17


@[a2956331800](/space/show?uid=9517) 你先用 `upper_bound` 找到第一个 $ > $ 的,再找其**前驱**即可 具体代码大概是长这样的 *233* ```c++ #include <bits/stdc++.h> using namespace std; int main(){ set<int> s; s.insert(500); s.insert(1000); set<int>::iterator iter = s.upper_bound(600); --iter; //找前驱 printf("%d\n", *iter); return 0; } ```
by yingjz @ 2018-12-22 17:02:01


| 下一页