// map::lower_bound/upper_bound #include #include using namespace std ; int main () { std::map mymap; std::map::iterator itlow,itup; mymap['a']=20; mymap['b']=40; mymap['c']=60; mymap['d']=80; mymap['e']=100; //lower bound just greater than equal to param //upper bound just greater than param itlow = mymap.lower_bound ('c'); // itup = mymap.upper_bound ('c'); // cout << itlow->first << endl ; cout << itup->first << endl ; std::map mymap1 ; mymap1['a']=20; mymap1['b']=40; //mymap1['c']=60; mymap1['d']=80; mymap1['e']=100; //lower bound just greater than equal to param //upper bound just greater than param itlow = mymap1.lower_bound ('c'); // itup = mymap1.upper_bound ('c'); // cout << itlow->first << endl ; cout << itup->first << endl ; return 0; }