1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <iostream>
#include <string>
#include <unordered_map>
using std::cout;
using std::cin;
using std::string;
using std::unordered_map;
int main() {
string name;
unordered_map<string, int> result;
while (1) {
cout << "name ? ";
getline(cin, name);
if (name.empty()) break;
result[name]++;
}
for (unordered_map<string, int>::iterator i = result.begin();
i != result.end(); i++)
cout << i->first << ": " << i->second << std::endl;
return 0;
}