记录单词个数

#include <iostream>
#include <map>
#include <string>

using namespace std;

int main()
{
map<string,int> word_count;
string word;
while(cin>>word)
{
pair<map<string,int>::iterator,bool> ret;
ret=word_count.insert(make_pair(word,1));
if(!ret.second)
{
++ret.first->second;
}
}

system("pause");
return 0;
}
posted @ 2013-04-28 06:03  码代码的猿猿  阅读(154)  评论(0编辑  收藏  举报