题目链接:https://vjudge.net/contest/211547#problem/C

题目大意:

输入一个文本,找出所有不同的单词(连续的字母序列),按字典序从小到大输出,单词不区分大小写。

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

……

#include<iostream>
#include<string>
#include<set>
#include<sstream>
using namespace std; set<string> dict;
string s, buf; int main() {
while(cin >> s) {
for(int i = ; i < s.length(); i++)
if(isalpha(s[i])) s[i] = tolower(s[i]); else s[i] = ' '; //一个一连串的字符串,如果带有其它符号,就会被分割成几个字符串
stringstream ss(s); //形成可能带有空格的字符串流
while(ss >> buf) dict.insert(buf); //将字符串流中的单词一个一个的存储在集合内
}
for(set<string>::iterator it = dict.begin(); it != dict.end(); ++it) //set具有给集合内元素去重和自动排序的功能
cout << *it << "\n";
return ;
}

2018-04-05

UVA 10815 Andy's First Dictionary【set】的更多相关文章

  1. UVa 10815 Andy's First Dictionary

    感觉这道题要比之前几个字符串处理的题目难度要大了一些. 题目大意:给若干行字符串,提取出所有单词并去掉重复的,最后按字典顺序输出. 对于输入大致有两种思路,一种是逐个读入字符,遇到字母的话就放到wor ...

  2. UVA - 10815 - Andy's First Dictionary STL

    Andy, 8, has a dream - he wants to produce his very own dictionary. This is not an easy task for him ...

  3. UVA 10815 Andy's First Dictionary (C++ STL map && set )

    原题链接: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_proble ...

  4. UVA 10815 Andy's First Dictionary ---set

    题目链接 题意:输入一个文本,找出所有不同的单词(连续的字母序列),按字典序从小到大输出.单词不区分大小写. 刘汝佳算法竞赛入门经典(第二版)P112 #include <iostream> ...

  5. Uva 10815 Andy's First Dictionary(字符串)

    题目链接:https://vjudge.net/problem/UVA-10815 题意 找出一段文本中的所有单词,以小写形式按照字典序输出. 思路 用空白符替换文本中所有非字母字符后再次读入. 代码 ...

  6. UVA 10815 Andy&#39;s First Dictionary(字符处理)

    Andy, 8, has a dream - he wants to produce his very own dictionary. This is not an easy task for him ...

  7. UVa 12325 Zombie's Treasure Chest【暴力】

    题意:和上次的cf的ZeptoLab的C一样,是紫书的例题7-11 不过在uva上交的时候,用%I64d交的话是wa,直接cout就好了 #include<iostream> #inclu ...

  8. UVa 10935 Throwing cards away I【队列】

    题意:给出 n张牌,从上往下编号依次为1到n,当牌的数目至少还剩下2张时,把第一张牌扔掉,然后把新的一张牌放在牌堆的最底部,问最后剩下的那一张牌是哪一张牌. 模拟队列的操作------- #inclu ...

  9. UVa 11054 Wine trading in Gergovia【贪心】

    题意:给出n个等距离的村庄,每个村庄要么买酒,要么卖酒,买酒和卖酒的总量相等, 把k个单位的酒从一个村庄运送到相邻的村庄,需要耗费k个单位劳动力,问怎样运送酒使得耗费的劳动力最少 买     卖    ...

随机推荐

  1. python技巧 列表推导

    val = [expression for value in collection if condition] 等价于 val = []for value in collection:    if c ...

  2. tr 设置margin、padding无效

    tr.td设置margin 无效 tr 设置padding无效.td设置padding有效

  3. PMM安装-第一篇

    一 简介 今天来聊聊 PMM安装使用 二 安装 1 server端执行   curl -sSL https://get.daocloud.io/docker | sh    docker pull p ...

  4. Mysql 插入中文错误:Incorrect string value: '\xE7\xA8\x8B\xE5\xBA\x8F...' for column 'course' at row 1

    create table my_user (    id tinyint(4) not null auto_increment,    account varchar(255) default nul ...

  5. SILC超像素分割算法详解(附Python代码)

    SILC算法详解 一.原理介绍 SLIC算法是simple linear iterative cluster的简称,该算法用来生成超像素(superpixel) 算法步骤: 已知一副图像大小M*N,可 ...

  6. ubuntu下安装intel realsense驱动

    在安装之前一定要确保系统是ubuntu 14.04.3 64位! 由于一开始安装的是32位系统,导致在升级内核版本到4.4时各种问题,最终靠重装系统解决. 因为intel给出的测试代码均是在64位14 ...

  7. fnmatch模块的使用

    fnmatch模块的使用 此模块的主要作用是文件名称的匹配,并且匹配的模式使用的unix shell风格.fnmatch比较简单就4个方法分别是:fnmatch,fnmatchcase,filter, ...

  8. linux 串口0x03,0x13的问题【转】

    linux 串口0x03,0x13的问题 本人最近在调linux串口的时候,发现其他数据接收正常,但是0x13怎么也接收不到,后面发现了这篇文章,两天的bug终于解决了,原来是linux底层uart配 ...

  9. mysql安装与卸载(阿里云)

    1.安装rpm包rpm -Uvh http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm 2.安装mysqlyum -y i ...

  10. windows系统安装jdk并设置环境变量

    CLASSPATH:JDK1.5之后的版本不需要配置.安装JDK 选择安装目录 安装过程中会出现两次安装提示 .第一次是安装 jdk ,第二次是安装 jre .建议两个都安装在同一个java文件夹中的 ...