Problem B: Andy's First Dictionary

Time limit: 3 seconds

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
给一篇文章。。然后生成一个字典。按字典序输出。。

set乱搞
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cctype>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#define ll long long
#define maxn 360
#define pp pair<int,int>
#define INF 0x3f3f3f3f
#define max(x,y) ( ((x) > (y)) ? (x) : (y) )
#define min(x,y) ( ((x) > (y)) ? (y) : (x) )
using namespace std;
char t[210],tem[210];
int main()
{
set <string> s;
while (gets(t))
{
int len=strlen(t),p;
for(int i=0;i<=len;)
{
if(isalpha(t[i]))
{
p=0;
tem[p++]=tolower(t[i]);
i++;
while(isalpha(t[i]))
tem[p++]=tolower(t[i++]);
tem[p++]='\0';string x(tem);s.insert(x);
}
else
i++;
}
}
set <string>::iterator it=s.begin();
while(it!=s.end())
{
cout<<*it<<endl;
it++;
}
return 0;
}

Uva 10815-Andy&#39;s First Dictionary(串)的更多相关文章

  1. 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 ...

  2. UVa 10815 Andy's First Dictionary

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

  3. 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 ...

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

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

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

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

  6. UVA 10815 Andy's First Dictionary【set】

    题目链接:https://vjudge.net/contest/211547#problem/C 题目大意: 输入一个文本,找出所有不同的单词(连续的字母序列),按字典序从小到大输出,单词不区分大小写 ...

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

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

  8. Andy&#39;s First Dictionary

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

  9. UVA - 11584 划分字符串的回文串子串; 简单dp

    /** 链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=34398 UVA - 11584 划分字符串的回文串子串: 简单 ...

  10. 安迪的第一个字典(Andy's First Dictionary,UVa 10815)

    Description Andy, , has a dream - he wants to produce his very own dictionary. This is not an easy t ...

随机推荐

  1. mysql 监控工具

    zabbix和grafana是绝配.  pmm的prometheus太占资源了

  2. 执行计划解读 简朝阳 (Sky Jian) and 那蓝蓝海

    http://greemranqq.iteye.com/blog/2072878 http://www.mysqlab.net/ http://www.mysqlpub.com/ http://blo ...

  3. Windows Server 2008 Standard Enterprise Datacenter各个版本区别

    -- Windows Server 2008 Standard 包含1个虚拟实例许可,5个客户端访问授权,售价999美元. -- Windows Server 2008 Enterprise 包含4个 ...

  4. find命令专辑

    find命令使用技巧 查找文件,移动到某个目录 使用find和xargs 15条 linux Find 命令实际使用方法 find 命令用法 find命令使用经验 find用法小结 find与xarg ...

  5. 【转载】利用Matlab制作钟表

    静态时钟 hObject=figure; set(hObject,'NumberTitle','off'); set(hObject,'MenuBar','none'); set(hObject,'v ...

  6. 38 个免费开源的 CSS 下拉导航菜单

    http://www.oschina.net/news/51624/38-open-source-css-dropdown-menus

  7. C#启动外部程序以及等待外部程序关闭的几种方法

    1. 启动外部程序,不等待其退出. 2. 启动外部程序,等待其退出. 3. 启动外部程序,无限等待其退出. 4. 启动外部程序,通过事件监视其退出. // using System.Diagnosti ...

  8. Flink 靠什么征服饿了么工程师?

    Flink 靠什么征服饿了么工程师? 2018-08-13    易伟平 阿里妹导读:本文将为大家展示饿了么大数据平台在实时计算方面所做的工作,以及计算引擎的演变之路,你可以借此了解Storm.Spa ...

  9. sqlalchemy: TimeoutError: QueuePool limit of size 5 overflow 10 reached, connection timed out, timeout 30

    mysql建立的连接要及时删除,不然连接池资源耗尽 相关文章参考: http://blog.csdn.net/robinson1988/article/details/4713294 http://b ...

  10. DICOM:DICOM三大开源库对比分析之“数据加载”

    背景: 上一篇博文DICOM:DICOM万能编辑工具之Sante DICOM Editor介绍了DICOM万能编辑工具,在日常使用过程中发现,“只要Sante DICOM Editor打不开的数据,基 ...