fork download
  1. #include <iostream>
  2. #include <set>
  3. using namespace std;
  4.  
  5. int main() {
  6. set<int> S = {1,2,3,4,5,6,0};
  7. for(auto it = S.begin(); it!=S.end(); /* don't do anything here*/ ) {
  8. if(*it % 2 == 0) it = S.erase(it);
  9. else {
  10. cout<<*it<<endl;
  11. it++;
  12. }
  13. }
  14. return 0;
  15. }
Success #stdin #stdout 0s 3472KB
stdin
Standard input is empty
stdout
1
3
5