(STL Preliminary) Mapping: Map

Source: Internet
Author: User
Tags month name

A map is a mapping from a key (key) to a value.

Because the [] operator is overloaded, the map image is an "advanced version" of the array.

For example, map<string,int>Month_name represents the mapping of "month name to month number".

Assignment mode: Month_name["July"]=7; (Similar to month_name["string"]=int)

Example 5-4

Problem

Most crossword puzzle fans is used to anagrams--groups of words with the same letters in different orders--for E Xample OPTS, SPOT, STOP, POTS and POST. Some words however do not has this attribute, no matter how to rearrange their letters, you cannot form another word. Such words is called ananagrams, a example is QUIZ.

Obviously such definitions depend on the domain within which we is working; You might think this athene is a ananagram, whereas any chemist would quickly produce ethane. One possible domain would be the entire 中文版 language, but this could leads to some problems. One could restrict the domain to, say, Music, in which case scale becomes a relative Ananagram (laces are not in t He same domain) but NOTE was not since it can produce TONE.

Write a program that would read in the dictionary of a restricted domain and determine the relative ananagrams. Note that single letter words is, ipso facto, relative ananagrams since they cannot is ' rearranged ' at all. The dictionary would contain no more than words.

Input

Input would consist of a series of lines. No line would be more than-characters long, but could contain any number of words. Words consist of up to upper and/or lower case letters, and is not being broken across lines. Spaces may appear freely around words, and at least one space separates multiple words on the same line. Note that words this contain the same letters but in differing case is considered to being anagrams of each other, thus TIeD and EdiT are anagrams. The file would be terminated to a line consisting of a single #.

Output

Output would consist of a series of lines. Each line would consist of a single word, a relative ananagram in the input dictionary. Words must is output in lexicographic (case-sensitive) order. There always is at least one relative ananagram.

Sample input
Ladder came tape soon leader Acme RIDE Lone Dreis Peat Scale orb  eye  Rides dealer  NotE derail laces  Driedn Oel dire Disk Mace Rob dries#

Sample output
Disknotederaildriedeyeladdersoon

Test instructions: Enter some words to find the words that meet the following criteria: The word cannot be re-queued by the letter to get another word in the input text. The letters are not case-sensitive when judging whether the condition is met.

However, the case in the input should be preserved in the output, arranged in dictionary order (all uppercase letters are preceded by all lowercase letters).

(STL Preliminary) Mapping: Map

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.