Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I have below program in C++. All input passing by command line argument. In here the key is string as word and Value is an

I have below program in C++. All input passing by command line argument. In here the key is string as word and Value is an int as number of frequency.

1) If the value of map repeated (duplicate), if so then and printout the There is duplicated

Example:

bag 2

bad 2

girl 2

We have to see if the frequnct is repeted. It stored already in the value of map.

2) What is most highest frequency in the map and printout the message.

#include

#include

#include

#include

#include

#include

#include

#include

#include

#include

using namespace std;

int main (int argc, char *argv[])

{

......

for (int i = 5; i < argc; i++)

{

ifstream inFile;

inFile.open (argv[i]);

if (!inFile.is_open ()

{

return 0;

}

}

}

for (int i = 5; i < argc; i++){

ifstream file (argv[i]);

string dataIn;

map < string, int > myMap;

// split words from input

while (file >> input)

{

// inc. count

myMap[dataIn]++;

}

map::iterator it;

for (it = myMap.begin(); it != myMap.end(); it++) {

// first is key AND second is value

cout << it->first << " " << it->second << endl;

// More code need to be added...

}

}

}

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

Oracle 10g SQL

Authors: Joan Casteel, Lannes Morris Murphy

1st Edition

141883629X, 9781418836290

More Books

Students also viewed these Databases questions