next up previous index
Next: The Program Up: Anagram-checking Previous: Anagram-checking

Problem Specification

Write a C++ program to determine whether or not a pair of consecutive lines typed at the keyboard are anagrams of one another. Two lines are anagrams of one another if they contain exactly the same characters in (perhaps) different order. For example, the following two lines are anagrams:

      Mildred Smedley
      slid remedy meld

Echo the two lines after they have been read. Then print one of the following messages followed by three blank lines:

      Yes, the above two lines are anagrams!
      No, the above two lines are not anagrams.

You may assume that no line contains more than 80 characters. You may also assume that the only characters in the lines are the 26 upper- and lowercase characters of the alphabet and the blank character. Ignore blanks in the input (except when the lines are echoed). Consider upper- and lowercase letters to be equal. Terminate your program when the first line of the pair contains less less than two characters.

Adapted from Nell Dale, Chip Weems, and John McCormick, Programming and Problem Solving with Ada, D. C. Heath and Co., 1994.



Kenny Zalewski
Mon May 13 04:03:40 EDT 1996