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;
        }
    
  • 相关阅读:
    如何改计算机用户名
    解决windows弹出'你可能是盗版软件的受害者...'及去除自动更新图标
    关于复制文件出现“Thumbs:访问被拒绝......”的解决办法和相关知识
    <百度分享平台>透明FLASH模块的方法
    绝对性解决打开我的电脑打开文件夹在新窗口中打开问题
    Git忽略规则(.gitignore配置)不生效原因和解决
    汇编学习笔记18
    汇编学习笔记21
    汇编学习笔记16
    汇编学习笔记22
  • 原文地址:https://www.cnblogs.com/lunatic-talent/p/12799104.html
Copyright © 2011-2022 走看看