wordfreq.cpp

来自「编程珠虮随书源码,非常好的软件工程学习思想.」· C++ 代码 · 共 21 行

CPP
21
字号
/* Copyright (C) 1999 Lucent Technologies */
/* From 'Programming Pearls' by Jon Bentley */

/* wordfreq.cpp -- List all words in input file, with counts */#include <iostream>#include <map>
#include <string>using namespace std;int main(){	map<string, int> M; 	map<string, int>::iterator j;
	string t;	while (cin >> t)
		M[t]++;	for (j = M.begin(); j != M.end(); ++j)
		cout << j->first << " " << j->second << "\n";
	return 0;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?