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的更多相关文章

  1. Problem C Andy's First Dictionary(set的使用)

    题目链接:Problem C 题意:输入一个文本,找出所有不同的单词,按照字典序从小到大输出,单词不区分大小写. 思路:将字母序列都存为小写,非字母的字符变成空格,然后利用stringstream实现 ...

  2. UVa 10815 Andy's First Dictionary

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

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

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

  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 (set)

    Andy's First Dictionary Description 不提英文了 直接上中文大意吧 XY学长刚刚立下了再不过CET就直播xx的flag,为了不真的开启直播模式,XY学长决定好好学习英 ...

  6. Andy's First Dictionary

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

  7. 安迪的第一个字典(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 ...

  8. 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 ...

  9. 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 ...

随机推荐

  1. 蓝桥杯之K好数问题

    问题描述 如果一个自然数N的K进制表示中任意的相邻的两位都不是相邻的数字,那么我们就说这个数是K好数.求L位K进制数中K好数的数目.例如K = 4,L = 2的时候,所有K好数为11.13.20.22 ...

  2. Minimum Inversion Number(归并排序)

    Minimum Inversion Number Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java ...

  3. 通过 CsvListWriter 读写.csv文件辅助类

    package cn.gov.cnis.db; import java.io.File; import java.io.FileReader; import java.io.FileWriter; i ...

  4. Sublime Text 3:3114的安装(目前最新),插件emmet的安装

    随便一些好了. 直接英文版吧,建议不要找中文版,学习英语不是? https://www.sublimetext.com/3   下载 https://github.com/wbond/package_ ...

  5. 遍历GridView

    ].Text+"--------------");                }            }

  6. bootstrap你让前端小狮子们又喜又恨

    看了一个用bootstrap框架建的页面,简直方便至极!各种添加类就可以实现各种功能,各种添加data-toggle让你不需要懂javascript就可以做出很炫的效果! 最重要的它做出来的页面还是响 ...

  7. perspective结合transform的3D效果

    http://css-tricks.com/almanac/properties/p/perspective/ 链接中讲了 perspective的两种用法及比较: 1.perspective:100 ...

  8. mobile&nbsp;web&nbsp;手机开发

    1.   -webkit-tap-highlight-color -webkit-tap-highlight-color:rgba(255,255,255,0); 用来把android上点击网页时出现 ...

  9. [转贴]JavaScript中Array(数组)的属性和方法

    数组有四种定义的方式 使用构造函数:var a = new Array();var b = new Array(8); var c = new Array("first", &qu ...

  10. png图片压缩优化

    1.2 软件环境 软件名称:Opting下载地址: http://optipng.sourceforge.net/ 安装版本:0.7.5安装位置:/apps/svr/opting 安装可能遇到的问题: ...