Advertisement
Morass

Set

Oct 13th, 2016
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.41 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. //...
  4. set<int> S={2 , 3 , 4 , 7 , 8 , 9};
  5. int main(void){
  6.     int X=7;
  7.     auto a=S.upper_bound(X);
  8.     cout<<*a<<endl;//first greater
  9.     auto b=S.lower_bound(X);
  10.     cout<<*b<<endl;//first greater/equal
  11.     auto c=S.lower_bound(X);
  12.     cout<<*--c<<endl;//first lower
  13.     auto d=S.upper_bound(X);
  14.     cout<<*--d<<endl;//first lower/equal
  15.     return 0;
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement