Sha 10815 Andy's First Dictionary (character processing)

Source: Internet
Author: User

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 wowould pick one of his favorite story books, from which he wowould 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 shoshould give a list of different words that appears in the input text, one in a line. the words shoshould 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 DisneylandTwo blondes were going to Disneyland when they came to a fork in theroad. The sign read: "Disneyland Left." So they went home.

Sample Output
Bytes
Construct a non-repeated Dictionary. Map it. (Case sensitive)
# Include <iostream> # include <cstdio> # include <cstring> # include <algorithm> # include <map> typedef long LL; using namespace std; # define REPF (I, a, B) for (int I = a; I <= B; ++ I) # define REP (I, n) for (int I = 0; I <n; ++ I) # define CLEAR (a, x) memset (a, x, sizeof a) map <string, int> p; struct node {char s [1100];} e [5500*200]; int cmp (node l1, node l2) {return strcmp (l1.s, l2.s) <0;} int m Ain () {std: ios: sync_with_stdio (false); char str [100]; int l = 0; while (scanf ("% s", str )! = EOF) {int len = strlen (str); // cout <"2333" <str <endl; REP (I, len) {int j; if (isalpha (str [I]) {char s1 [1100]; int ll = 0; for (j = I; j <len; j ++) {if (isalpha (str [j]) s1 [ll ++] = tolower (str [j]); else break;} s1 [ll] = '\ 0 '; if (! P [s1]) {p [s1] = 1; strcpy (e [l ++]. s, s1) ;} I = J-1 ;}} sort (e, e + l, cmp); REP (I, l) cout <e [I]. s <endl; return 0 ;}


Sha 10815 Andy's First Dictionary (character processing)

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.