123456789101112131415161718192021
#include <iostream> #include <string> #include <map> using namespace std; int main() { map<string, int> m; string str; while(cin>>str) { if(str == "end") break; m[str]++; cout<<str<<" frequency = "<<m[str]<<endl; } return 0; }
12345
i frequency = 4 me frequency = 1 we frequency = 3 you frequency = 2 can frequency = 1