zoukankan      html  css  js  c++  java
  • 2019/02/11训练日记

    从吃完晚饭开始码代码,看到有个题有思路,便开始坐下来敲代码,发现这个题跟平常做过的题,有相似之处。
    但真的敲起来,还真是有困难。

    Andy, 8, has a dream - he wants to produce his very own dictionary.
    This is not an easy task for him, as the number of words that he knows
    is, well, not quite enough. Instead of thinking up all the words
    himself, he has a briliant idea. From his bookshelf he would pick one
    of his favourite story books, from which he would copy out all the
    distinct words. By arranging the words in alphabetical order, he is
    done! Of course, it is a really time-consuming job, and this is where
    a computer program is helpful.

    You are asked to write a program that lists all the different words in
    the input text. In this problem, a word is defined as a consecutive
    sequence of alphabets, in upper and/or lower case. Words with only one
    letter are also to be considered. Furthermore, your program must be
    CaSe InSeNsItIvE. For example, words like “Apple”, “apple” or “APPLE”
    must be considered the same.

    Input
    The input file is a text with no more than 5000 lines. An input
    line has at most 200 characters. Input is terminated by EOF.

    Output

    Your output should give a list of different words that appears in the
    input text, one in a line. The words should all be in lower case,
    sorted in alphabetical order. You can be sure that he number of
    distinct words in the text does not exceed 5000.

    Sample Input

    Adventures in Disneyland

    Two blondes were going to Disneyland when they came to a fork in the
    road. The sign read: “Disneyland Left.”

    So they went home.

    Sample Output

    a

    adventures

    blondes

    came

    disneyland

    fork

    going

    home

    in

    left

    read

    road

    sign

    so

    the

    they

    to

    two

    went

    were

    when

    大小写替换tolower()
    关于Set容器的小总结。
    set容器能够通过平衡二叉树排序,时间复杂度log(n),自动去重(其实无法放入重复元素)
    定义:
    set<类型> 名称;
    操作:
    1.有类似字符串的操作方式
    2.放入容器 名称.insert(要放入项目)
    3.迭代器 set<类型>::iterator 名称 类似指针可以自增自减,不能加减整数
    4.通过迭代器
    举例如下

    set<string>::iterator i;
        for(i=a.begin();i!=a.end();++i)
        {
            cout<<*i<<endl;
        }
    
  • 相关阅读:
    堆排序
    归并排序
    Distinct Subsequences——Leetcode
    Longest Consecutive Sequence——Leetcode
    Different Ways to Add Parentheses——Leetcode
    Haproxy 安装配置详解
    Saltstack常用模块
    SaltStack之安装
    tcpcopy复制线上流量
    nginx配置详解与优化
  • 原文地址:https://www.cnblogs.com/lunatic-talent/p/12799105.html
Copyright © 2011-2022 走看看