Advertisement
Guest User

Untitled

a guest
Feb 19th, 2020
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.44 KB | None | 0 0
  1. #include <iostream>
  2. #include <map>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7. #define D(x) cout << #x << " " << x << endl
  8.  
  9. int main() {
  10.     int n;
  11.     cin >> n;
  12.     D(n);
  13.     map<string, int> trees;
  14.     for(int i = 0; i < n; ++i) {
  15.         string currTree;
  16.         cin >> currTree;
  17.         trees[currTree] += 1;
  18.     }
  19.     map<string,int>::iterator it;
  20.     for(it = trees.begin(); it != trees.end(); ++it) {
  21.         cout << it -> first << " " << it -> second << endl;
  22.     }
  23.     return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement