Mega Code Archive
Categories
/
C++
/
Map Multimap
Use transform() to create map from two arrays
#include
#include
#include
#include
using namespace std; int main( ) { const char* word[] = { "A", "B", "C", "D","E" }; const char* clue[] = { "a", "b","c", "d","e" }; map
dictionary1; transform( word, word+sizeof(word)/sizeof(word[0]), clue,inserter( dictionary1, dictionary1.end() ),make_pair
); cout << "There are " << dictionary1.size() << " words in the dictionary\n\n"; }