#include <algorithm>
#include <iostream>
#include <map>
#include <utility>
using namespace std;
int main( )
{
const char* word[] = { "A", "B", "C", "D","E" };
const char* clue[] = { "a", "b","c", "d","e" };
map<string,string> dictionary1;
transform( word, word+sizeof(word)/sizeof(word[0]), clue,inserter( dictionary1, dictionary1.end() ),make_pair<string,string> );
typedef multimap<string,string> Dictionary;
Dictionary dictionary2( dictionary1.begin(),dictionary1.end() );
dictionary2.insert( make_pair( "POPS", "Bursts" ) );
dictionary2.insert( make_pair( "POPS", "Fathers" ) );
dictionary2.insert( make_pair( "ADAM", "Madam" ) );
pair<Dictionary::iterator,Dictionary::iterator> range = dictionary2.equal_range( "POPS" );
for( Dictionary::iterator i = range.first; i != range.second; ++i )
cout << "\nPOPS - " << i->second;
for( Dictionary::iterator i = dictionary2.begin();
i != dictionary2.end(); ++i )
cout << i->first << " - " << i->second << endl;
}
|