zoukankan      html  css  js  c++  java
  • 【UVa 10815】Andy's First Dictionary

    真的只用set和string就行了。

    如果使用PASCAL的同学可能就要写个treap什么的了,还要用ansistring。

    #include<cstdio>
    #include<cstring>
    #include<iostream>
    #include<string>
    #include<set>
    using namespace std;
    
    string s;
    string now;
    set<string> dict;
    
    bool is_alpha(char &c)
    {
        if (c >= 'a' && c <= 'z') return true;
        if (c >= 'A' && c <= 'Z')
        {
            c = c - 'A' + 'a';
            return true;
        }
        return false;
    }
    
    int main()
    {
        dict.clear();
        while(cin >> s)
        {
            now = string("");
            for (int i = 0; i < s.length(); ++i)
                if (is_alpha(s[i])) now += s[i];
                else
                {
                    if (now != "") dict.insert(now);
                    now = string("");
                }
            if (now != "") dict.insert(now);
        }
        for (set<string>::iterator it = dict.begin(); it != dict.end(); ++it)
            cout << *it << "
    ";
        return 0;
    }
  • 相关阅读:
    结对开发地铁
    学习进度04
    构建之法阅读笔记02
    学习进度03
    构建之法阅读笔记01
    Golang开发工具LiteIDE使用方法整理
    package httputil
    package net
    package json
    package encoding
  • 原文地址:https://www.cnblogs.com/albert7xie/p/4729273.html
Copyright © 2011-2022 走看看