Question: C++ Using STL Multimap Need help with: I have the code that retrieves the map values and displays to the map, now I need to

C++ Using STL Multimap

Need help with: I have the code that retrieves the map values and displays to the map, now I need to input the resulting values from the map and transpose them in a multimap and output the letters in the order of its occurrence(amount of times each letter is repeated within the string). (arranged from: least # of times --- to greatest # of times repeated).

Example of what I need:

Enter a text string: fghjkjhjhhjkfgdfghjk The frequency table: [d]->1 [f]->3 [g]->3 [h]->5 [j]->5 [k]->3 The occurance table - a transposed multimap: [1]->d [3]->f [3]->g [3]->k [5]->h [5]->j 

******************************************************************

what I have:

#include  #include  #include  using namespace std; void getFrequency(string strInput,mapchar,int> & fMap) { mapchar,int>::iterator it; //iterator to find the entries in map for(int i = 0 ; i char ch = strInput.at(i); it = fMap.find(ch); //find the character in the map if( it == fMap.end() ) //if not present in the map { fMap.insert( make_pair(ch,1) );//add an entry } else  { it->second++; //else increment the frequency } } } void printFrequency(mapchar,int> & fMap) { mapchar,int>::iterator it;//iterator to loop through all the chars for( it = fMap.begin() ; it != fMap.end() ; ++it ) { coutfirst">strInput; mapchar,int> frequencyMap; //frequency map getFrequency(strInput, frequencyMap); //get the frequencies printFrequency(frequencyMap); //print the frequencies } 

SAMPLE OUTPUT:

C++ Using STL Multimap Need help with: I have the code that

Run Build All /Users/Hokage/Desktop/CS165/fifteen/cmake-build-debug/fifteen Please enter the string that will be examined: bilinyethescienceguy [c]->2 el->4 [1]--2 [nl->2 2 Process finished with exit code 0 Run Build All /Users/Hokage/Desktop/CS165/fifteen/cmake-build-debug/fifteen Please enter the string that will be examined: bilinyethescienceguy [c]->2 el->4 [1]--2 [nl->2 2 Process finished with exit code 0

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!