fork download
  1. #include <iostream>
  2. #include <map>
  3. #include <algorithm>
  4. #include <string>
  5. #include <unordered_map>
  6.  
  7. using namespace std;
  8.  
  9.  
  10.  
  11. int main() {
  12.  
  13. unordered_map<int, size_t> counts;
  14.  
  15.  
  16. std::map<std::string, int> m = {
  17. {"XzbitYmay", 64},
  18. {"Bruce Watson", 53},
  19. {"Nim George", 53},
  20. {"Lee Harry", 64},
  21. {"Nim George", 59 }};
  22.  
  23. for(const auto& kvp : m) {
  24. counts[kvp.second]++;
  25. }
  26.  
  27. for(const auto& kvp: counts) {
  28. if(kvp.second > 0)
  29. std::cout << kvp.first << "->" << kvp.second << '\n';
  30. }
  31.  
  32. return 0;
  33. }
Success #stdin #stdout 0s 4408KB
stdin
Standard input is empty
stdout
64->2
53->2