How to print value of a hash map according to increasing/decreasing order of key in c++? -


if have map,

map <int,int> m; 

and following key value pair (-2,3) , (-14,8) , (4,8), (6,12) , (3,76)

now if want print value in increasing order of keys,then how print ?

o/p

8 3 76 8 12

the keys in std::map ordered default (using operator<). can iterate on map:

for (std::map<int, int>::iterator = m.begin(); != m.end(); i++) {     cout << i->second << "\n"; } 

Comments

Popular posts from this blog

java - BeanIO write annotated class to fixedlength -

Using Java 8 lambdas/transformations to combine and flatten two Maps -

How to connect android app to App engine -