Last active
July 20, 2019 06:12
-
-
Save manojnaidu619/73bf237df814272ab05bd5f0915a68a1 to your computer and use it in GitHub Desktop.
Maps(STL) in C++
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <map> | |
using namespace std; | |
int main(){ | |
map<int,string> m; | |
m.insert(pair<int,string>(1,"Apple")); | |
m.insert(pair<int,string>(2,"Banana")); | |
m.insert(pair<int,string>(3,"Litchi")); | |
map<int,string>::iterator itr; | |
for(itr=m.begin();itr!=m.end();itr++){ | |
cout << itr->first << " " << itr->second; | |
cout << endl; | |
} | |
map<int,string>::iterator itr1; | |
itr1=m.find(3); | |
cout << "Value found is : " << itr1->second << endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment