fork download
  1. #include <iostream>
  2. #include <map>
  3. #include <string>
  4. using namespace std;
  5. int main() {
  6. int n;
  7. cin >> n;
  8. map<string, int> word_count;
  9. string word;
  10. for (int i = 0; i < n; ++i) {
  11. cin >> word;
  12. word_count[word]++;
  13. }
  14. for (auto &pair : word_count) {
  15. cout << pair.first << ": " << pair.second << endl;
  16. }
  17.  
  18. return 0;
  19. }
  20.  
Success #stdin #stdout 0.01s 5324KB
stdin
9  
mymap['b'] = 100;
  mymap['a'] = 200;
  mymap['c'] = 300;
stdout
100;: 1
200;: 1
300;: 1
=: 3
mymap['a']: 1
mymap['b']: 1
mymap['c']: 1