UVa 10815 Andy's First Dictionary
来源:互联网 发布:知乎匿名提问 编辑:程序博客网 时间:2024/05/19 15:23
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 de ned as a consecutive se-
quence of alphabets, in upper and/or lower case.
Words with only one letter are also to be considered. Furthermore, your program must be CaSe In-
SeNsItIvE. For example, words like \Apple", \apple" or \APPLE" must be considered the same.
Input
The input le 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.
SampleInput
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.
SampleOutput
a
adventures
blondes
came
disneyland
fork
going
home
in
left
read
road
sign
so
the
they
to
two
went
were
when
#include <stdio.h>#include <stdlib.h>#include <string.h>#include <ctype.h>#define N 210#define N1 5100char s[N1][N];int cmp(const void * a, const void *b) {return strcmp((char *) a, (char *) b);}int main() {int t = 0, p = 0;char ch;while ((ch = getchar()) != EOF) {if (isalpha(ch)) s[p][t++] = tolower(ch);else if (t > 0) {s[p][t] = '\0';p++;t = 0;}}qsort(s, p, N, cmp);for (int i = 0; i <= p - 1; i++) {if (strcmp(s[i], s[i+1]) == 0)continue;printf("%s\n", s[i]);}return 0;}
0 0
- UVa OJ 10815-Andy's First Dictionary
- uva 10815 Andy's First Dictionary
- UVa 10815 - Andy's First Dictionary
- UVA 10815 - Andy's First Dictionary
- uva-10815 - Andy's First Dictionary
- UVa 10815 - Andy's First Dictionary
- UVA 10815 Andy's First Dictionary
- UVa 10815 - Andy's First Dictionary
- UVA 10815 Andy's First Dictionary
- UVa-10815 - Andy's First Dictionary
- UVA 10815 - Andy's First Dictionary
- uva -- 10815 Andy's First Dictionary
- UVA 10815 Andy's First Dictionary
- uva 10815 Andy's First Dictionary
- UVa 10815 - Andy's First Dictionary
- uva - 10815 - Andy's First Dictionary
- UVA 10815 Andy's First Dictionary
- Uva 10815 - Andy's First Dictionary
- poj3207Ikki's Story IV - Panda's Trick tarjan缩点
- 零基础学python-1.3 通过idle启动python
- 剑指offer刷题之java实现的栈的压入、弹出序列
- [php] 常用header
- 剩余系,剩余定理,同余定理,费马小定理的证明
- UVa 10815 Andy's First Dictionary
- LeetCode #1 Two Sum
- win7 64位 鼠标右键explorer重启解决方法
- 读书笔记之c和指针(8)
- Linux网络编程(2)——采用TCP的基本server的实现
- 简单记录一下简单的理解
- 【Linux学习】epoll详解
- 随机查找数组中第i个元素(按顺序排列的)
- hdu2993