-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path93maps.cpp
More file actions
24 lines (21 loc) · 893 Bytes
/
93maps.cpp
File metadata and controls
24 lines (21 loc) · 893 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
#include<iostream>
#include<map>
using namespace std;
int main(){
// Map is an associative array
map<string,int> mapMArks; // string will be this map's first and int will be second
mapMArks["Bhumi"] = 23;
mapMArks["Swami"] = 24;
mapMArks["Nami"] = 53;
mapMArks["Kami"] = 99;
mapMArks.insert({{"King Crimson", 999}, {"Piccolo", 34}}); // syntax for insert
map<string,int> :: iterator iter;
for(iter = mapMArks.begin(); iter != mapMArks.end(); iter++){
// iter is now pointing to a position in the map
cout<<(*iter).first<<": "<<(*iter).second<<endl;
}
cout<<"The size of the map is: "<<mapMArks.size()<<endl;
cout<<"The max size of the map is: "<<mapMArks.max_size()<<endl;
cout<<"The empty's return value is: "<<mapMArks.empty()<<endl; // no empty values so returns 0
return 0;
}