UVA 10815 Andy's first dictionary

Source: Internet
Author: User
Tags stdin strcmp strtok
10815-andy ' s Dictionary

Time limit:3.000 seconds

Problem B:andy ' s-Dictionary

Time Limit:3 seconds



Andy, 8, has a dream-he wants to produce his very own. This isn't a easy task for him, as the number of words which is, a, not quite enough. Instead of thinking up all the words himself, he has a briliant idea. From him bookshelf he would pick one of his favourite story books, from which to he would copy of the distinct. By arranging the "words in alphabetical", he is done! Of course, it is a really time-consuming job, and that is where a computer the program is helpful.

You are are asked to write a program which lists all the different words in the input text. In this problem, a word was defined as a consecutive sequence of alphabets, in upper and/or. Words with only one letter are also to be considered. Furthermore, your program must is case insensitive. For example, words like "apple", "apple" or "apple" must is considered the same.

Input

The input file is a-text with no more than 5000 lines. An input line has at most characters. The Input is terminated by EOF.

Output

Your output should give a list of different words that appears into the input text, one in a line. The words should all is in lower case and sorted in alphabetical order. You can is sure that him number of distinct words in the text does not exceed 5000.

Sample Input
Adventures in Disneyland

Two blondes were going to Disneyland while 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


/************************************************************************* > File name:10815.cpp > Author: Shorey > Mail:shoreybupt@gmail.com > Created time:2014 year November 27 Thursday 15:36 43 sec ***************************** /#include <iostream> #include <stdio.h> #include <
Stdlib.h> #include <string.h> using namespace std;
Char Line[202],word[5000][20],tmp[20],*tmpword;
int num=0; int main () {char seps[]= ",?!.: \"
	\ n ";
	Freopen ("Data.in", "R", stdin);
		while (Fgets (Line,202,stdin)!=null) {Tmpword=strtok (line,seps);
		   while (Tmpword!=null) {for (int i=0;i<strlen (tmpword); i++) Tmpword[i]=tolower (tmpword[i));
		   strcpy (Word[num++],tmpword);

		Tmpword=strtok (null,seps); (int i=0;i<num-1;i++) for (int j=0;j<num-1-i;j++) {if (strcmp (word[j],word[j+1)) >0) {STRCP
				Y (Tmp,word[j]);
				strcpy (word[j],word[j+1]);
			strcpy (WORD[J+1],TMP); for (inti=0;i<num;i++) {if (strcmp (word[i],word[i+1)) printf ("%s\n", Word[i]);
return 0;
 }


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.