Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!