統計文件中的單詞
#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");
}
統計文件中的單詞
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.