fork download
  1. #include <iostream>
  2. #include <set>
  3. using namespace std;
  4.  
  5. int main() {
  6. set<int> a;
  7. a.insert(1);
  8. a.insert(5);
  9. //a.insert(6);
  10. a.insert(7);
  11. set<int>::iterator it = a.upper_bound(6);
  12. if (it != a.begin()) {
  13. it--;
  14. cout << *it << endl;
  15. }
  16. return 0;
  17. }
Success #stdin #stdout 0s 4512KB
stdin
Standard input is empty
stdout
5