计算一段字符串中单词的个数

#include
#include
#include 
#include 
using namespace std;
void CountWords()
{
	//ifstream is("/*打开输入文件*/");
	//ofstream os("/*打开输出文件*/");

	map mp;
	map::iterator it;
	string str;
	getline(cin,str);
	int j=0;
	int len=str.length();
	for (int i=0;i>str)
	{
		if(str =="EOF")
			break;
		++mp[str];
	}
	for(it=mp.begin();it!=mp.end();it++) //遍历  
    {  
        cout<first<<' '<<"occurs "<second<

你可能感兴趣的:(计算一段字符串中单词的个数)