fork download
  1. #include <iostream>
  2. #include <map>
  3. #include <string>
  4. using namespace std;
  5.  
  6. int main() {
  7. std::map<std::string, int> map;
  8. map.emplace("Bob", 3);
  9. map.emplace("Jim", 4);
  10. map.emplace("Tom", 1);
  11. map.emplace("Sarah", 2);
  12. map.emplace("Jake", 6);
  13. for(auto& x : map)
  14. {
  15. std::cout << x.first << " " << x.second << "\n";
  16. }
  17. }
Success #stdin #stdout 0s 3232KB
stdin
5
Bob
Jim
Tom
Sarah
Jake
stdout
Bob 3
Jake 6
Jim 4
Sarah 2
Tom 1