fork download
  1. #include <iostream>
  2. #include <map>
  3. #include <string>
  4. using namespace std;
  5.  
  6. int main() {
  7. map<int, string> m;
  8. m.insert({1, "a"});
  9. m.insert({1, "b"});
  10. m.insert({2, "c"});
  11. m.erase(2);
  12.  
  13. m.insert({2, "d"});
  14. for(auto i = m.begin(); i != m.end(); i++) {
  15. cout << i->first << " : " << i->second << endl;
  16. }
  17.  
  18. // your code goes here
  19. return 0;
  20. }
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
1 : a
2 : d