统计文件中的单词
#include <string>
#include <iostream>
#include <fstream>
#include <map>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
ifstream in;
in.open("1.txt");
map<string,int>word;
string s;
while(in>>s)
word[s]++;
map<string,int>::iterator it=word.begin();
for(it;it!=word.end();it++)
cout<<it->first<<" "<<it->second<<endl;
system("pause");
}
统计文件中的单词
最新推荐文章于 2023-06-08 20:06:10 发布