fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. // your code goes here
  6. map<int,int> m;
  7. m[0]=0;
  8. m[1]=1;
  9. m[2]=2;
  10. m[3]=3;
  11.  
  12. // auto it = m.begin();
  13. for(auto it = m.begin(); it!=m.end();)
  14. {
  15. cout << it->second << endl;
  16. if(it->second == 3) it = m.erase(it);
  17. else ++it;
  18. }
  19. return 0;
  20. }
Success #stdin #stdout 0.01s 5508KB
stdin
Standard input is empty
stdout
0
1
2
3