Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write two C++ programs to determine whether or not a pair of consecutive lines read from an input file Download anagram.txt are anagrams of one

Write two C++ programs to determine whether or not a pair of consecutive lines read from an input file Download anagram.txt 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:

anagram.txt

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 can 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 characters (space, tab, etc). 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 than two characters.

HINT

You can determine if two strings are anagrams by

1. Remove all blanks 2. Make all upper case letters to lower case 3. Sort the lines 4. Compare if the two lines are identical

You must develop two versions for the anagram; one with STL and one without STLfor storing and manipulating data, and sorting. Although we didn't discuss various sorting algorithms in depth yet, sorting a few words (bubble sort, or insertion sort) won't be that much of a work if you use cstring libraries.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Pro Android Graphics

Authors: Wallace Jackson

1st Edition

1430257857, 978-1430257851

Students also viewed these Programming questions

Question

14. Let X be uniform over (0, 1). Find E[X|X Answered: 1 week ago

Answered: 1 week ago