#include #include #include using std::cin; using std::cout; using std::endl; using std::map; using std::string; int main() { string s; map counters; // store each word and an associated counter // read the input, keeping track of each word and how often we see it while (cin >> s) ++counters[s]; // write the words and associated counts #ifdef _MSC_VER for (std::map::const_iterator it = counters.begin(); #else for (map::const_iterator it = counters.begin(); #endif it != counters.end(); ++it) { cout << it->first << "\t" << it->second << endl; } return 0; }