// 1009.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include <map> #include <string> #include <iostream> using namespace std; int _tmain(int argc, _TCHAR* argv[]) { map<string,int> word_count; string word; cout << "Enter words:"; while (cin >> word) ++word_count[word]; cout << "Output the counter for every word" << endl; for (map<string,int>::iterator iter = word_count.begin();iter != word_count.end();iter++) { cout << iter->first << " " << iter->second << endl; } return 0; }