-
Notifications
You must be signed in to change notification settings - Fork 0
/
Map.cpp
26 lines (26 loc) · 858 Bytes
/
Map.cpp
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
#include <string.h>
#include <iostream>
#include <map>
#include <utility>
using namespace std;
int main()
{
map<int, string> Employees;
Employees[101] = "Nikita";
Employees[105] = "John";
Employees[103] = "Dolly";
Employees[104] = "Deep";
Employees[102] = "Aman";
cout << "Employees[104]=" << Employees[104] << endl << endl;
cout << "Map size: " << Employees.size() << endl;
cout << endl << "Natural Order:" << endl;
for( map<int,string>::iterator ii=Employees.begin(); ii!=Employees.end(); ++ii)
{
cout << (*ii).first << ": " << (*ii).second << endl;
}
cout << endl << "Reverse Order:" << endl;
for( map<int,string>::reverse_iterator ii=Employees.rbegin(); ii!=Employees.rend(); ++ii)
{
cout << (*ii).first << ": " << (*ii).second << endl;
}
}