fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. map<string,int,greater<>> m;
  6. m["anjali"]=10;
  7. m["ayushi"]=20;
  8. m.insert(make_pair("nisha",30));
  9. m.insert(pair<string,int>("sneha",50));
  10. map<string,int>::iterator it,it1,it2;
  11. cout<<m.lower_bound("ayushi")->first;
  12. cout<<" "<<m.upper_bound("ayushi")->first<<'\n';
  13. //cout<<it1->first<<" "it2->first<<'\n';
  14. for(it=m.begin();it!=m.end();it++)
  15. cout<<it->first<<" "<<it->second<<'\n';
  16. // your code goes here
  17. return 0;
  18. }
Success #stdin #stdout 0s 4440KB
stdin
Standard input is empty
stdout
ayushi anjali
sneha 50
nisha 30
ayushi 20
anjali 10