HDU2072 单词数[入门]
程序中使用set、(字符串流)中的istringstream以及string。
stringstream通常是用来做数据转换的。
/* HDU2072 单词数 */
#include <iostream>
#include <cstdio>
#include <sstream>
#include <set>
using namespace std;
int main()
{
string s;
while(getline(cin, s) && s != "#") {
istringstream sin(s);
set<string> words;
string w;
while(sin >> w)
words.insert(w);
cout << words.size() << endl;
}
return 0;
}