basic ex of maps in c 2b 2b

Solutions on MaxInterview for basic ex of maps in c 2b 2b by the best coders in the world

showing results for - "basic ex of maps in c 2b 2b"
Alejandra
09 Nov 2017
1#include <iostream> 
2#include <iterator> 
3#include <map> 
4   
5using namespace std; 
6   
7int main() 
8{ 
9     map<int, int> marks; 
10     marks.insert(pair<int, int>(160, 42)); 
11     marks.insert(pair<int, int>(161, 30)); 
12     marks.insert(pair<int, int>(162, 40)); 
13     marks.insert(pair<int, int>(163, 50)); 
14     marks.insert(pair<int, int>(164, 31)); 
15     marks.insert(pair<int, int>(165, 12)); 
16     marks.insert(pair<int, int>(166, 34)); 
17   
18     map<int, int>::iterator itr; 
19     cout << "nThe map marks is : n"; 
20     cout << "ROLL NO.tMarksn"; 
21     for (itr =  marks.begin(); itr !=  marks.end(); ++itr) { 
22        cout  << itr->first 
23             << "t   t" << itr->second << 'n'; 
24     } 
25     cout << endl; 
26     return 0;     
27  }
28