C++Primer 练习11.20

/*
*author @alex
*title C++Primer 练习11.20
*/


int main(int argc, char **argv) {
	map<string, int> word_count;
	string word;
	ifstream in("ss.txt");
	while (in >> word)
	{
		auto ret = word_count.insert({ word,1 });
		if (!ret.second)
			++ret.first->second;
	}
	for (auto wi : word_count) {
		cout << wi.first << " " << wi.second << endl;
	}
}

猜你喜欢

转载自blog.csdn.net/dididisailor/article/details/82835300