#include <iostream>
#include <algorithm>
#include <vector>
#include <ctime>

using namespace std;

int main(){
    int a[] = {1, 2, 4, 5, 6};
    
    int *p = lower_bound(a, a + 5, 3);//lower_bound指返回大于等于三的地址 第一个值是起始位 第二个值是最后一个变量的后一个位置
    
    int t = lower_bound(a, a + 5, 7) - a;//-a可以返回他的下标
    int d = upper_bound(a, a + 5, 3) - a;
    //upper_bound可以返回严格大于这个值的第一个位置
    
    cout << d << endl;
    cout << t << endl;
    cout << *p << endl;
    
    //他返回的是一个迭代器 在数组里也就是返回一个指针
     
    
    vector<int> w{1, 2, 4, 5, 6};
    
    int q = lower_bound(w.begin(), w.end(), 3) - w.begin();
    cout << w[q] << endl;
    return 0;
}