-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path65maps.cpp
More file actions
32 lines (27 loc) · 920 Bytes
/
Copy path65maps.cpp
File metadata and controls
32 lines (27 loc) · 920 Bytes
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
#include <iostream>
#include <cstring>
#include <fstream>
#include <map>
using namespace std;
// MAP IS AN ASSOCIATIVE CONTAINER
int main()
{
map<string, int> marks;
map<string, int> payment;
// MAP TAKES TWO TYPES OF DATA TYPES AS IT MAPS ON DATA TO ANOTHER DATA, i.e. BINDS A KEY TO THE VALUE
// Method to insert values...
marks["Vasu"] = 45;
marks["Aenansh"] = 50;
marks["Dev"] = 34;
marks.insert({"Singh", 12});
marks.insert({{"Ramu", 9}, {"Kaka", 27}});
map<string, int>::iterator itr;
for (itr = marks.begin(); itr != marks.end(); itr++)
{
cout << (*itr).first << " " << itr->second << endl;
}
cout<<"The size of the marks map is : "<<marks.size()<<endl;
cout<<"Maximum size to accomodate the data is : "<<marks.max_size()<<endl;
cout <<"1 for empty container, 0 for full : "<<marks.empty()<<" / "<<payment.empty()<<endl;
return 0;
}