a.cpp 765 B

1234567891011121314151617181920
  1. #include <unordered_map>
  2. #include <iostream>
  3. int main()
  4. {
  5. std::unordered_map<int, std::string> c = {{1, "one"}, {2, "two"}, {3, "three"},
  6. {4, "four"}, {5, "five"}, {6, "six"}};
  7. // 从 c 擦除所有奇数
  8. for(auto it = c.begin(); it != c.end(); )
  9. if(it->first % 2 == 1)
  10. it = c.erase(it);
  11. else
  12. ++it;
  13. c.erase(2);
  14. c.erase(2);
  15. c.erase(7);
  16. for(auto& p : c)
  17. std::cout << p.second << ' '<<std::endl;
  18. std::string s="";
  19. std::cout << std::stoi(s)<<std::endl;
  20. }