fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5. // Declaring umap to be of <string, int> type
  6. // key will be of string type and mapped value will
  7. // be of double type
  8. unordered_map<string, int> umap;
  9.  
  10. // inserting values by using [] operator
  11. umap["GeeksforGeeks"] = 10;
  12. umap["Practice"] = 20;
  13. umap["Contribute"] = 30;
  14.  
  15. // Traversing an unordered map
  16. for (auto x : umap)
  17. cout << x.first << " " << x.second << endl;
  18.  
  19. }
Success #stdin #stdout 0s 4568KB
stdin
Standard input is empty
stdout
Contribute 30
GeeksforGeeks 10
Practice 20