codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
#include <iostream> #include <vector> #include <string> #include <map> using namespace std; int main() { typedef vector<string> vector_str_t; map<string, vector_str_t> a_map; typedef map<string, vector_str_t>::iterator it_t; pair<it_t, bool> pr = a_map.insert(make_pair("rock", vector_str_t())); pr.first->second.push_back("hard"); pr.first->second.push_back("solid"); pr.first->second.push_back("unbreakable"); cout<< "Contents of map:\n\n"; for (it_t it = a_map.begin(); it != a_map.end(); it++) { cout<< "Current key contents: " << it->first <<endl; cout<< "Current mapped value contents: "; vector<string> vct = it->second; for (unsigned int i = 0; i < vct.size(); i++) { if (i != 0) cout<< "\t\t\t "; cout<< vct.at(i) <<endl; } } return 0; }
Private
[
?
]
Run code
Submit