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