Richard Golz
2
Q:

upper bound in c++

// ForwardIterator upper_bound (ForwardIterator first, ForwardIterator last, const T& val, Compare comp);
std::vector<int>::iterator upper1, upper2; 
  
    // std :: upper_bound 
    upper1 = std::upper_bound(v.begin(), v.end(), 35); 
    upper2 = std::upper_bound(v.begin(), v.end(), 45); 
  
    std::cout << "\nupper_bound for element 35 is at position : " 
              << (upper1 - v.begin()); 
    std::cout << "\nupper_bound for element 45 is at position : "
              << (upper2 - v.begin()); 
0

New to Communities?

Join the community