[ create a new paste ] login | about

Link: http://codepad.org/7IEbweSe    [ raw code | output | fork ]

C++, pasted on Jan 6:
#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;
}


Output:
1
2
3
4
5
6
Contents of map:

Current key contents: rock
Current mapped value contents: hard
			       solid
			       unbreakable


Create a new paste based on this one


Comments: