Question
This program should be created using maps. It also should work with any example and not just the ones below. Write a C++ program that
This program should be created using maps. It also should work with any example and not just the ones below.
Write a C++ program that reads from the standard input and counts the number of times each word is seen. A word is a number of non-whitespace characters separated by whitespace.
After all input has been processed, print each word that was seen the largest number of times on a line by itself. The words should be printed in alphabetical order.
For example, with the input
Hello ... I said Hello are you there?
your program should print out
Hello
since it was the word that appeared most frequently in the input.
With the input
bow wow bow wow
the program should print out two lines:
bow
wow
Because both of those words appeared most frequently in the input.
If there is no input, your program should generate no output.
It should have something like this in there
map
string word;
while( cin>> word )
counters[word]++;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started