upper_bound()

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
    vector<int>a = {1,2,3,4,5,6,7,8,9,10};
    auto t = upper_bound(a.begin(), a.end(), 7);
    if(t == a.end())
        cout << 7 << " is not found." << endl;
    else
        cout << 7 << " is found." << endl;

    return 0;
}

Comments