Andy's First Dictionary
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's First Dictionary的更多相关文章
- UVa 10815 Andy's First Dictionary
感觉这道题要比之前几个字符串处理的题目难度要大了一些. 题目大意:给若干行字符串,提取出所有单词并去掉重复的,最后按字典顺序输出. 对于输入大致有两种思路,一种是逐个读入字符,遇到字母的话就放到wor ...
- UVa10815.Andy's First Dictionary
题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...
- Problem C: Andy's First Dictionary
Problem C: Andy’s First DictionaryTime Limit: 1 Sec Memory Limit: 128 MBSubmit: 18 Solved: 5[Submit] ...
- 【UVA - 10815】Andy's First Dictionary (set)
Andy's First Dictionary Description 不提英文了 直接上中文大意吧 XY学长刚刚立下了再不过CET就直播xx的flag,为了不真的开启直播模式,XY学长决定好好学习英 ...
- UVA-10815 Andy's First Dictionary (非原创)
10815 - Andy's First Dictionary Time limit: 3.000 seconds Problem B: Andy's First DictionaryTime lim ...
- 安迪的第一个字典(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 ...
- STL语法——集合:set 安迪的第一个字典(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 ...
- 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 ...
- Winter-2-STL-E Andy's First Dictionary 解题报告及测试数据
use stringstream Time Limit:3000MS Memory Limit:0KB Description Andy, 8, has a dream - he wants ...
随机推荐
- Android关机流程源码分析
上一篇文章Android 开关机动画显示源码分析详细介绍了开关机动画的显示过程,Android系统开机时,在启动SurfaceFlinger服务过程中通过Android属性系统方式来启动bootani ...
- 清风注解-Swift程序设计语言:Point6~10
目录索引 清风注解-Swift程序设计语言 Point 6. 输出常量和变量 代码事例: // 输出的内容会在最后换行 println("hello, world") // 输出的 ...
- Android之SplashActivity的巧妙之处
众所周知,我们很多应用都会有一个SplashActivity,用来当作进入应用的第一个过度界面,显示一个logo信息.如下所示,是我的简洁天气的SplashActivity. 但是,它的作用仅仅只是用 ...
- express中路由设置的坑-----1
router.get('/commodities/sortable', utils.logged, function (req, res) { Commodity.find({force_top:tr ...
- 从零开始Unity3D游戏开发【3烘焙】
烘焙:通过烘焙能把动态场景转化为静态场景.从而提高游戏的性能. [烘焙步骤] 1.Edit---Player---Rendering[forword] 2.Directional light(必须是这 ...
- Request.ServerVariables完整参考
Request.ServerVariables("Url") 返回服务器地址 Request.ServerVariables("Path_Info") 客户端提 ...
- C#高效导出Excel(IList转DataTable,DataSet)
微软的Excel操作类导出Excel会很慢,此方法简单的把表中内容以字符串的形式写入到Excel中,用到的一个技巧就是"\t". C#中的\t相当于Tab键,写入到Excel中时就 ...
- 兼容现有jQuery API的轻量级JavaScript库:Zepo
Zepo是一个JavaScript框架,其特点是兼容现有jQuery API的同时,自身体积十分小:它与jQuery有着类似的API.如果你会jQuery,那么也就会使用Zepto了. $('div' ...
- Python学习笔记 (1) :python简介、工具、编码及基础运算
学习背景: 精通一门编程语言并编写出自己喜欢的程序是我多年的梦想,一定要找时间实现.此时想起了高中时的我对编程的兴趣十分浓厚,父母给自己购买了学习机插卡式的,只能敲basic代码,同时学校有386计算 ...
- BOM 浏览器对象模型学习
window对象属性 innerWidth/innerHeight 浏览器窗口的内部宽度与高度 outerWidth/outerHeight 浏览器的外部宽度与高度 length window.fra ...