fork download
  1. # include <iostream>
  2. # include <algorithm>
  3. using namespace std;
  4. int a[]={1,1,3,4};
  5. int main()
  6. {
  7. int *p2=upper_bound(a,a+4,1);
  8.  
  9. cout << "upper_bound returned element " << p2-a << '\n' ;
  10.  
  11. cout<< "which is " << *p2<<endl;
  12. }
Success #stdin #stdout 0s 3340KB
stdin
Standard input is empty
stdout
upper_bound returned element 2
which is 3