fork(1) download
  1. #include <iostream>
  2. #include <set>
  3. #include <iterator>
  4. #include <algorithm>
  5. using namespace std;
  6. int main() {
  7. set<int> oldset;
  8. for (int i = 0; i < 10; ++i) oldset.insert(i);
  9.  
  10. copy(oldset.begin(), oldset.end(), ostream_iterator<int>(cout));
  11. cout << endl;
  12.  
  13. // cut [b, e)
  14. set<int>::iterator b = oldset.find(3);
  15. set<int>::iterator e = oldset.find(7);
  16. set<int> newset(b, e);
  17. oldset.erase(b, e);
  18.  
  19. copy(oldset.begin(), oldset.end(), ostream_iterator<int>(cout));
  20. cout << endl;
  21. copy(newset.begin(), newset.end(), ostream_iterator<int>(cout));
  22. cout << endl;
  23. }
  24.  
Success #stdin #stdout 0.02s 2816KB
stdin
Standard input is empty
stdout
0123456789
012789
3456