Problem C: Andy's First Dictionary
Problem C: Andy’s First Dictionary
Time Limit: 1 Sec Memory Limit: 128 MB
Submit: 18 Solved: 5
[Submit][Status][Web Board]
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
my answer:
#include<iostream>
#include<algorithm>
#include<stdlib.h>
#include<cmath>
#include<stdio.h>
#include<cstring>
#include<string>
using namespace std;
char * dtox(char a[])//函数。。。由大写转化成小写 ;
{
int t1=strlen(a);
for (int i=;i!=t1;i++)
if(a[i]>='A'&&a[i]<='Z')
a[i]=a[i]+;
return a;
}
char * quza(char b[])//函数。。。去掉符号部分;
{
int t2=strlen(b);
char s[];
int f=;
dtox(b);
for(int j=;j!=t2;j++){
if(b[j]>='a'&&b[j]<='z')
s[f++]=b[j];
}
s[f]='\0';
return s;
}
int main()
{ char a[][],word[][];
int i=,k=;
while(gets(a[i]))
{
int t=strlen (a[i]);
if(t==)
continue;
char *p;
p=strtok(a[i]," ");
while(p)
{
strcpy(word[k++],quza(p));
p=strtok(NULL," ");
} i++;
}
//sort (word[0],word[0]+k);
for(int t=;t!=k;t++){
int w=t;
for(int m=t;m!=k;m++)
if(strcmp(word[w],word[m])>)w=m;
char r[];
strcpy(r,word[w]);
strcpy(word[w],word[t]);
strcpy(word[t],r);
}
for (int h=;h!=k;h++){
if(strcmp(word[h],word[h+]))
cout <<word[h]<<endl;
}
return ;
}
Problem C: Andy's First Dictionary的更多相关文章
- Problem C Andy's First Dictionary(set的使用)
题目链接:Problem C 题意:输入一个文本,找出所有不同的单词,按照字典序从小到大输出,单词不区分大小写. 思路:将字母序列都存为小写,非字母的字符变成空格,然后利用stringstream实现 ...
- UVa 10815 Andy's First Dictionary
感觉这道题要比之前几个字符串处理的题目难度要大了一些. 题目大意:给若干行字符串,提取出所有单词并去掉重复的,最后按字典顺序输出. 对于输入大致有两种思路,一种是逐个读入字符,遇到字母的话就放到wor ...
- UVA-10815 Andy's First Dictionary (非原创)
10815 - Andy's First Dictionary Time limit: 3.000 seconds Problem B: Andy's First DictionaryTime lim ...
- UVa10815.Andy's First Dictionary
题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...
- 【UVA - 10815】Andy's First Dictionary (set)
Andy's First Dictionary Description 不提英文了 直接上中文大意吧 XY学长刚刚立下了再不过CET就直播xx的flag,为了不真的开启直播模式,XY学长决定好好学习英 ...
- Andy's First Dictionary
Description Andy, 8, has a dream - he wants to produce his very own dictionary. This is not an easy ...
- 安迪的第一个字典(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 ...
随机推荐
- Netfilter-packet-flow.svg
调试网络的方法:(Debugging the kernel using Ftrace) $ watch -n1 -d sudo cat /proc/net/snmp$ watch -n1 -d su ...
- /dev/null &
java -cp .:ojdbc14.jar com.eucalyptus.dataguard.DBCheck dadifilm slbcheck Aa7788123 > /dev/null & ...
- 枚举与剪枝_观察算式(比标准答案还要牛B)
观察算式 观察以下的算式: △△△ * △△ = △△△△ 某3位数乘以2位数,结果为4位数 要求:在9个△所代表的数字中.1~9的数字恰好每一个出现1次. 暴力破解代码: package lianx ...
- 应用java多线程实现server端与多client之间的通信
应用多线程来实现server与多线程之间的通信的基本步骤 1.server端创建ServerSocket,循环调用accept()等待client链接 2.client创建一个Socket并请求和se ...
- mac 版本号控制工具SmartSVN7.5.4(破解版)
SmartSVN7.5.4和破解工具,下载地址:http://download.csdn.net/detail/pearlhuzhu/7407319 操作步骤: 1.在MAC上选中smartsvn-m ...
- XX秘籍
第一课 一个男人在他妻子洗完澡后准备进浴室洗澡.这时,门铃响了. 妻子迅速用浴巾裹住自己冲到门口. 当她打开门时,邻居鲍勃站在那儿. 在她开口前,鲍勃说,“你如果把浴巾拿掉,我给你800美元.” 想了 ...
- English - 英文写作中的最常见“十大句式”
英文写作中的最常见“十大句式” from 小木虫论坛 一.否定句 许多否定句不含not的否定结构.如果论文作者能正确使用他们,就会增加写作的闪光点,使文章显得生动活泼. 1.Instead of in ...
- Oracle操作数据库oracleHelper
1 Oracle OracleHelper //============================================================================ ...
- C#根据文件流判断文件类型
判断文件真实的类型,不是通过扩展名来判断: /// <summary> /// 判断文件格式 /// http://www.cnblogs.com/babycool /// </su ...
- java中文件保存、打开文件对话框
package com.soft.test; //AWT: FileDialog类 + FilenameFilter类 可以实现本功能 //Swing: JFileChooser类 + FileFil ...