记录单词个数

#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;
}
原文地址:https://www.cnblogs.com/CKboss/p/3351082.html