Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- //...
- set<int> S={2 , 3 , 4 , 7 , 8 , 9};
- int main(void){
- int X=7;
- auto a=S.upper_bound(X);
- cout<<*a<<endl;//first greater
- auto b=S.lower_bound(X);
- cout<<*b<<endl;//first greater/equal
- auto c=S.lower_bound(X);
- cout<<*--c<<endl;//first lower
- auto d=S.upper_bound(X);
- cout<<*--d<<endl;//first lower/equal
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement