【刘汝佳书】例题5-3 UVA10815 (set的练习)

【2019.4.3】
vjudge一下午没登陆上
气得我刷了一节课虎扑
因为电脑要没电了
所以勉强去官网提交了

#include <iostream>
#include <set>
#include <cctype>
#include <string>

using namespace std;

int main()
{
    //freopen("C:\\Users\\Summer\\Desktop\\input.txt", "r", stdin);
    //freopen("C:\\Users\\Summer\\Desktop\\output.txt", "w", stdout);

    char c;
    string aWord = "";
    set<string> words;
    while((c=getchar()) != EOF) {
        if(isalpha(c)) {
            c = tolower(c);
            aWord += c;
            //cout<< aWord <<endl;
        }
        else {
            if(aWord != "")
                words.insert(aWord);
            aWord = "";
        }
    }
    if(aWord != "")
        words.insert(aWord);

    set<string>::iterator it;
    for(it = words.begin(); it != words.end(); it++)
        cout<< *it <<endl;
    return 0;
}

猜你喜欢

转载自blog.csdn.net/qq_41727666/article/details/88998552