fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. vector<int>v={1,2,4,4,5};
  5.  
  6. void lb(int num){
  7. cout<<lower_bound(v.begin(),v.end(),num)-v.begin()<<endl;
  8. }
  9.  
  10. int main() {
  11. lb(3); //if number is not present
  12. lb(4); //if number is present
  13. lb(7); //if number if bigger than max
  14. return 0;
  15. }
Success #stdin #stdout 0.01s 5272KB
stdin
Standard input is empty
stdout
2
2
5