language: C++ 4.7.2 (gcc-4.7.2)
date: 209 days 12 hours ago
link:
visibility: public
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <iostream>
#include <utility>
#include <iomanip>
#include <map>
 
using namespace std;
typedef pair<int, int> Key; //pair
 
void display (map <Key,float> &m) // to print maps
{
    cout << "\tTotal size: " << m.size() << endl; 
    map <Key,float>::iterator it;
    for (it = m.begin(); it != m.end(); ++it)
       cout << setw(10) << it->first.first << it->first.second << setw(5) << it->second << endl;
 
    cout << endl; 
}
 
int main() {
 
map< Key , float> mapa; //create map
 
Key p1 (1, 45); //key values
Key p2 (2, 20);
 
mapa[p1]= 25.11; //map float to keys
mapa[p2]= 11.23;
 
display(mapa); //display map
 
return 0;
 
}