Use upper_bound on vector : vector bound « vector « C++ Tutorial






#include <iostream>
#include <cassert>
#include <algorithm>
#include <vector>
using namespace std;

int main()
{
  vector<int> v(5);
  bool found;

  v[1] = 7; v[2] = 7; v[3] = 7; v[4] = 8;

  vector<int>::iterator k;
  k = upper_bound(v.begin(), v.end(), 7);
  cout << *k;

  return 0;
}
8








16.6.vector bound
16.6.1.Use lower_bound on vector
16.6.2.Use upper_bound on vector