hdu 2072

题目链接


按常规方法得考虑各种情况,比较麻烦

学习了一下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)  //>>每次输入以空格或'\0'结束
        t.insert(s);   //插入

        cout<<t.size()<<endl;  //返回不同的值的个数

    }
    return 0;
}


 

 

posted on 2013-08-14 18:39  bbsno  阅读(142)  评论(0)    收藏  举报

导航