#include <bits/stdc++.h>
using
namespace
std;
void
printMap(map<
int
,
int
> sampleMap)
{
map<
int
,
int
>::iterator itr;
for
(itr = sampleMap.begin();
itr != sampleMap.end();
++itr) {
cout << itr->first
<<
" = "
<< itr->second <<
", "
;
}
cout << endl;
}
pair<
int
,
int
> findEntryWithLargestValue(
map<
int
,
int
> sampleMap)
{
pair<
int
,
int
> entryWithMaxValue
= make_pair(0, 0);
map<
int
,
int
>::iterator currentEntry;
for
(currentEntry = sampleMap.begin();
currentEntry != sampleMap.end();
++currentEntry) {
if
(currentEntry->second
> entryWithMaxValue.second) {
entryWithMaxValue
= make_pair(
currentEntry->first,
currentEntry->second);
}
}
return
entryWithMaxValue;
}
int
main()
{
map<
int
,
int
> sampleMap;
sampleMap.insert(pair<
int
,
int
>(1, 40));
sampleMap.insert(pair<
int
,
int
>(2, 30));
sampleMap.insert(pair<
int
,
int
>(3, 60));
cout <<
"Map: "
;
printMap(sampleMap);
pair<
int
,
int
> entryWithMaxValue
= findEntryWithLargestValue(sampleMap);
cout <<
"Entry with highest value: "
<< entryWithMaxValue.first <<
" = "
<< entryWithMaxValue.second << endl;
return
0;
}