Skip to content

Instantly share code, notes, and snippets.

@manojnaidu619
Last active July 20, 2019 06:12
Show Gist options
  • Save manojnaidu619/73bf237df814272ab05bd5f0915a68a1 to your computer and use it in GitHub Desktop.
Save manojnaidu619/73bf237df814272ab05bd5f0915a68a1 to your computer and use it in GitHub Desktop.
Maps(STL) in C++
#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