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

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -