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. Get buck-boost performance from a boost regulator

    The SEPIC (single-ended, primary-inductance-converter) topology is generally a good choice for volta ...

  2. 源码分析:动态分析 Linux 内核函数调用关系

    源码分析:动态分析 Linux 内核函数调用关系 时间 2015-04-22 23:56:07  泰晓科技 原文  http://www.tinylab.org/source-code-analysi ...

  3. iOS Sqlite加密(FMDB/SQLCipher)

    /** * 对数据库加密 * * @param path path description * * @return return value description */ + (BOOL)encryp ...

  4. 利用tca时间聚簇分析方法分析fmri数据

    一.利用ica进行fmri数据分解时,在得到相互独立的成分后,这些成分的后续处理,其实是有很多文章可以做的.比如,对这些成分进行排序和选择.如果能够提出某种方法,能够自动地制造特征,并将这些特征与分解 ...

  5. PHP闭包--匿名函数

    匿名函数(Anonymous functions),也叫闭包函数(closures),允许 临时创建一个没有指定名称的函数.最经常用作回调函数(callback)参数的值.当然,也有其它应用的情况. ...

  6. 第十四章 openwrt 安装 python

    需要安装libffi,python-mini,python.libffi以及python-mini需要安装在python之前     如果部分软件包不一样可以在下面的web后台搜索,搜索前先opkg ...

  7. OpenERP|odoo Web开发

    在OpenERP 7 和 Odoo 8下测试均可. 1.相关库/框架 主要:jQuery(使用1.8.3,如果使用新版本,其他jQuery插件也要升级或修改).Underscore.Qweb 其他:都 ...

  8. Python基础(12)--模块

    本文地址:http://www.cnblogs.com/archimedes/p/python-modules.html,转载请注明源地址. 模块简介 如果你退出 Python 解释器重新进入,以前创 ...

  9. [AngularJS] ng-change vs $scope.$watch

    <div class="form-group"> <label for="pwd">Password</label> < ...

  10. SELECT语句逻辑运行顺序,你知道吗?

    引言 这不是一个什么多深的技术问题.多么牛叉的编程能力.这跟一个人的开发能力也没有很必定的直接关系,可是知道这些会对你的SQL编写,排忧及优化上会有很大的帮助.它不是一个复杂的知识点.可是一个很基础的 ...