Skip to content

Instantly share code, notes, and snippets.

@tanvir002700
Created April 16, 2016 17:28
Show Gist options
  • Select an option

  • Save tanvir002700/1e71b27d3025d4287da88f39f992aaec to your computer and use it in GitHub Desktop.

Select an option

Save tanvir002700/1e71b27d3025d4287da88f39f992aaec to your computer and use it in GitHub Desktop.
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main ()
{
int myints[] = {10,20,30,30,20,10,10,20,50,1,39,40};
vector<int> v(myints,myints+12);
sort (v.begin(), v.end());
vector<int>::iterator low,up;
low=lower_bound (v.begin(), v.end(), 20);
up= upper_bound (v.begin(), v.end(), 30);
cout<<"Total element in range [20,30]: "<<up-low<<endl;
return 0;
}
Total element in range [20,30]: 5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment