fork download
  1. // C++ program to illustrate the use of std::lower_bound
  2. #include <bits/stdc++.h>
  3. using namespace std;
  4.  
  5. int main() {
  6. vector<int> v = {10, 20, 30, 35,35,35, 40, 40, 40, 50,50};
  7.  
  8. // Finding lower bound for value 35 in vector v
  9. cout <<upper_bound(v.begin(), v.end(), 20) - lower_bound(v.begin(), v.end(), 50);
  10.  
  11. return 0;
  12. }
Success #stdin #stdout 0.01s 5316KB
stdin
Standard input is empty
stdout
-7