I have a map implementation where the identifier is stored as a value and marked as a key. This allows me to use automatic sorting on maps and allows me to identify the identifier of the item with the highest marks.
for(map<int, int>::iterator i = marks.begin(); i != marks.end(); ++i) cout << i->first << "\t" << i->second << endl; cout << marks.rbegin()->second << endl; cout << marks.end()->second << endl;
produces this conclusion:
312 3 420 4 512 2 752 1 1 420
The input sequence was an increase in the order of values. Why doesn't end() display "1", but instead display the key of the last pair entered? What is the difference between rbegin() and end() ?
Naman source share