#include <iostream>
#include <sstream>
#include <string>
#include <map>
using namespace std;
int main()
{
string s;
while (getline(cin, s)){
if (s == "#"){
break;
}
stringstream in(s);
string ss;
map<string, int> mp;
int cnt = 0;
while (in >> ss){
mp[ss]++;
if (mp[ss] == 1){
cnt++;
}
}
cout << cnt << endl;
}
return 0;
}hdu 2072 单词数(C++的stringstream对象)
最新推荐文章于 2020-11-17 00:02:14 发布
本文介绍了一个使用C++编写的简单程序,该程序能够从输入的字符串中统计不同单词的数量。通过使用标准模板库(STL)中的map容器来记录每个单词出现的次数,并在最后输出所有唯一单词的数量。
3万+

被折叠的 条评论
为什么被折叠?



