Description

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

HINT

#include<stdio.h>
#include<string.h>
char a[5000];
int t;
void zhuanhuan() //大写和小写转换
{
int i;
for(i=0;i<t;i++)
{
if(a[i]>='A'&&a[i]<='Z')
a[i]=a[i]+32;
}
}
int main()
{
char b[5000][200];
int i,j,m,n;
m=0;
int flag;
while(gets(a))//scanf("%s",a)!=EOF
{
j=0;
n=0;
t=strlen(a);
if(t==0)
continue;
zhuanhuan();
for(i=0;i<t;i++)
{
if((a[i]<='z'&& a[i]>='a'))
b[m][n++]=a[i];
else if(a[i]==' ')
{
b[m][n++]='\0';
m++;
n=0;
}
}
b[m++][n]='\0';
}
for(i=m-1;i>=0;i--)
{
for(j=0;j<i;j++)
{
if(strcmp(b[j],b[j+1])>0)
{
char w[30];
strcpy(w, b[j]);
strcpy(b[j],b[j+1]);
strcpy(b[j+1],w);
}
}
}
for(i=0;i<m;i++)
{
flag=1;
for(j=0;j<i;j++)
{
if((strcmp(b[i],b[j]))==0)
{
flag=0;
break;
} }
if(flag==1)
printf("%s\n",b[i]);
}
//for(i=0;i<m;i++)
// printf("%s\n",b[i]);
return 0;
}

版权声明:本文博客原创文章,博客,未经同意,不得转载。

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&#39;s First Dictionary(串)

    Problem B: Andy's First Dictionary Time limit: 3 seconds Andy, 8, has a dream - he wants to produce ...

  3. Swift语法3.03(类型Types)

    类型 在Swift中,有两种类型:命名型类型和复合型类型.命名型类型是在定义时可以给定的特定名字的类型.命名型类型包括类,结构体,枚举和协议.例如,自定义的类MyClass的实例拥有类型MyClass ...

  4. UVa10815.Andy's First Dictionary

    题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...

  5. UVA-10815 Andy's First Dictionary (非原创)

    10815 - Andy's First Dictionary Time limit: 3.000 seconds Problem B: Andy's First DictionaryTime lim ...

  6. UVa 10815 Andy's First Dictionary

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

  7. Andy's First Dictionary

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

  8. Problem C: Andy's First Dictionary

    Problem C: Andy’s First DictionaryTime Limit: 1 Sec Memory Limit: 128 MBSubmit: 18 Solved: 5[Submit] ...

  9. 安迪的第一个字典(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. silentScroll() 滚屏

    jQuery.mobile.silentScroll( yPos ) 滚动到一个特定的Y坐标位置,没有触发涡旋的事件监听器 yPos:Y坐标.类型:数字.默认值: //滚屏到y 100px处 $.mo ...

  2. Ext的异步请求(二级级联动态加载下拉列表)

    页面: <tr> <td class="label" width="300" >作业计划项模板</td> <td> ...

  3. Oracle undo 镜像数据探究

                                                                 Oracle undo 镜像数据探究  今天是2013-08-18,隔别一周的 ...

  4. Java8 Lamdba表达式 001

    在一个已经存在的编程语言里非常少有对现有的生态系统起重大影响的新特性.Lambda表达式对于Java语言就是这样的意义的存在.简单来说,Lambda表达式提供了便利的方式去创建一个匿名的功能.提供了一 ...

  5. MFC:重绘Button,定制CButton,自画CPngButton,求赐教(各种bug包括性能bug)谢谢谢谢

    [1.]CPngButton.h(资源是最后图片) #pragma once #include<atlimage.h> #define PNUM 19 #define PLAYTIME 1 ...

  6. asp.net 中将汉字转换成拼音

    /// <summary> /// 获取汉字的全拼音 /// </summary> /// <param name="x">传汉字的字符串< ...

  7. Swift - 添加、修改、删除通讯录联系人

    使用AddressBook.framework框架,我们除了可以很方便的获取通信录里的联系人.同时,还能对通讯录进行新增.修改.删除联系人操作. (注意:这些操作同查询一样,首先需要发起授权请求) 1 ...

  8. CSS中怎么让DIV居中(转载)

    CSS 如何使DIV层水平居中 今天用CSS碰到个很棘手的问题,DIV本身没有定义自己居中的属性, 网上很多的方法都是介绍用上级的text-align: center然后嵌套一层DIV来解决问题. 可 ...

  9. (摘录)26个ASP.NET常用性能优化方法

    数据库访问性能优化 数据库的连接和关闭 访问数据库资源需要创建连接.打开连接和关闭连接几个操作.这些过程需要多次与数据库交换信息以通过身份验证,比较耗费服务器资源. ASP.NET中提供了连接池(Co ...

  10. Qt之文件操作 QFile

    原地址:http://blog.csdn.net/liuhongwei123888/article/details/6084761 今天学习QT的文件操作 1.QIODevice直接继承自QObjec ...