按常规方法得考虑各种情况,比较麻烦
学习了一下STL的应用
#include <iostream>
#include <sstream>
#include <string>
#include <set>
using namespace std;
set<string> t;
int main()
{
string s,row;
while(getline(cin,row)&& row!="#") //按行输入
{
t.clear();
stringstream str;
str<<row; //类型转换
while(str>>s) //>>每次输入以空格或' '结束
t.insert(s); //插入
cout<<t.size()<<endl; //返回不同的值的个数
}
return 0;
}