lower_bound() && distance()

#include<iostream>
#include<vector>
#include<iterator>
using namespace std;
int main()
{
    vector<int> v = {1,2,3,4,5,6,7,8,9};
    vector<int> :: iterator t;
    t = lower_bound(v.begin(), v.end(), 9);
    cout << *t << endl;
    cout << distance(v.begin(), t) << endl;

    return 0;
}

Comments