STL-二分查找
upper_bound、lowe_bound、binary_search
upper_bound、lowe_bound
1. 返回的是地址
2. 如果找不到,返回 右邊界下標+1 或者 0
- 升序
int *a = lower_bound( first,last, key ): 第一個 >= key 的地址
int b = upper_bound( first,last, key ):第一個* > key** 的地址 - 降序
第四個參數 greater< Type >()
lower_bound( first,last, key, greater< Type >()): 第一個 <= key 的地址
upper_bound( first,last, key, greater< Type >()):第一個* < key* 的地址
binary_search
二分查找,返回bool,三個參數,起始地址,數組長度,查找值。
與50位技術專家面對面20年技術見證,附贈技術全景圖總結
- 上一篇: 子序列问题
- 下一篇: 2018年长沙理工大学第十三届程序设计竞