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

时间: 2024-11-03 01:25:47

Andy&#39;s First Dictionary的相关文章

Uva 10815-Andy&amp;#39;s First Dictionary(串)

Problem B: Andy's First Dictionary Time limit: 3 seconds 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

C#中的Dictionary字典类常用方法介绍

1 using System.Collections.Generic;//引用命名空间//Dictionary可以理解为散列集合 2 public class DictionaryTest 3 { 4 public static void Main() 5 { 6 //1.初始化 7 Dictionary<string, string> dicA = new Dictionary<string, string>(); 8 //2.添加元素 key,value->学号,姓名 9

游戏UI框架设计(二) : 最简版本设计

最简版本设计 --最简版本设计 为降低难度决定先讲解一个最简版本,阐述UI框架的核心设计理念.这里先定义三个核心功能: 1:UI窗体的自动加载功能. 2:缓存UI窗体. 3:窗体生命周期(状态)管理. UI框架设计主要目的,就是尽可能的完成一些与具体游戏功能逻辑无关的一些底层事务性的功能实现.这些功能最好是自动或者是半自动的实现,无须客户程序(调用框架的程序)过多处理与关心. 对于以上功能,笔者定义了UI框架的相关四个核心类: BaseUIForms    基础UI窗体脚本(父类,其他窗体都继承

wcf系列学习5天速成——第四天 wcf之分布式架构

原文:wcf系列学习5天速成--第四天 wcf之分布式架构 今天是wcf系列的第四天,也该出手压轴戏了.嗯,现在的大型架构,都是神马的, nginx鸡群,iis鸡群,wcf鸡群,DB鸡群,由一个人作战变成了群殴....... 今天我就分享下wcf鸡群,高性能架构中一种常用的手法就是在内存中维护一个叫做“索引”的内存数据库, 在实战中利用“索引”这个概念做出"海量数据“的秒杀. 好,先上图: 这个图明白人都能看得懂吧.因为我的系列偏重于wcf,所以我重点说下”心跳检测“的实战手法. 第一步:上一下

C# 敏捷1

1 using System; 2 using System.Collections; 3 using System.Collections.Generic; 4 using System.Diagnostics; 5 using System.Linq; 6 using System.Text; 7 using System.Threading.Tasks; 8 9 namespace ConsoleApplication2 10 { 11 public class Post 12 { 13

=-098765

http://ypk.39.net/search/all?k=%A1%B8%D4%E6%D1%F4%C3%D4%BB%C3%D2%A9%D4%F5%C3%B4%B9%BA%C2%F2Q%A3%BA%A3%B6%A3%B9%A3%B5%A3%B2%A3%B5%A3%B6%A3%B7%A3%B1%A3%B7%A8%7C http://ypk.39.net/search/all?k=%A8%93%D2%CB%B3%C7%C3%D4%BB%C3%D2%A9%D4%F5%C3%B4%B9%BA%C2%F2

UVA - 10815 Andy&#39;s First Dictionary

1 #include <iostream> 2 #include <cstring> 3 #include <algorithm> 4 #include <set> 5 using namespace std; 6 7 set<string> out; 8 9 int main() 10 { 11 string s,temp; 12 while(cin>>s) 13 { 14 int len(s.size()); 15 for(int

Winter-2-STL-E Andy&#39;s First Dictionary 解题报告及测试数据

use stringstream Time Limit:3000MS     Memory Limit:0KB 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 thin

Andy&#39;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. F