fork download
  1. #include <iostream>
  2. #include <set>
  3. using namespace std;
  4.  
  5. int main() {
  6. set<int> h;
  7. set<int>::iterator i;
  8. h.insert(2);
  9. i = h.find(2);
  10. cout<<"two: "<<*i<<endl;
  11. // cout<<"position: "<<i-h.begin()<<endl; // compilation error
  12. h.insert(3);
  13. i++;
  14. i--;
  15. cout<<"three-one: "<<*i<<endl;
  16. // cout<<"position: "<<i-h.begin()<<endl; // compilation error
  17. h.insert(1);
  18. cout<<"one+one: "<<*i<<endl;
  19. // cout<<"position: "<<i-h.begin()<<endl; // compilation error
  20. return 0;
  21. }
Success #stdin #stdout 0s 4316KB
stdin
Standard input is empty
stdout
two: 2
three-one: 2
one+one: 2