📄 words_count_4.cpp
字号:
/*
* Description:
*
* Report the amount of the defferent words in your input.
*
* History:
*
* Initial version created by Royal, Mar. 2004.
*
* Notes:
*
* This code has been written to conform to standard C++ and STL. It has been
* compiled successfully using GNU C++ 3.2, Borland C++ 5.5, and Visual C++ 7.0.
*/
#include <iostream>
#include <string>
#include <map>
using namespace std;
int main()
{
string word;
map<string, int> words;
cout << "Please input words:";
while (cin >> word) ++words[word];
map<string, int>::const_iterator it = words.begin();
map<string, int>::const_iterator end_it = words.end();
while (it != end_it)
{
cout << "There are/is " << it->second << " \"" << it->first << "\" in your input." << endl;
++it;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -