10815 - Andy‘s First Dictionary(UVA)

题目链接如下:

Online Judge

代码如下:

#include 
#include 
#include 
#include 
// #define debug

int main(){
    #ifdef debug
    freopen("0.txt", "r", stdin);
    freopen("1.txt", "w", stdout);
    #endif
    char ch;
    std::set st;
    while(scanf("%c", &ch) != EOF){
        while(!isalpha(ch)){
            scanf("%c", &ch);
        }
        std::string str;
        do{
            str.push_back(tolower(ch));
            scanf("%c", &ch);
        } while(isalpha(ch));
        st.insert(str);
    }
    for(auto it = st.begin(); it != st.end(); ++it){
        printf("%s\n", (*it).c_str());
    }
    #ifdef debug
    fclose(stdin);
    fclose(stdout);
    #endif
    return 0;
}

你可能感兴趣的:(UVA,算法)