#include <algorithm>
#include <iostream>
int main()
{
const int heightCount = 8;
int kidHeights[heightCount] = { 1, 3, 6, 5, 6, 4, 2, 3 };
// your first for loop
auto maxHeightIter = std::max_element(kidHeights, kidHeights + heightCount);
// your second for loop
auto maxHeightCount = std::count(kidHeights, kidHeights + heightCount, *maxHeightIter);
std::cout
<< "Highest kid is " << *maxHeightIter
<< " unit(s) high and number " << maxHeightIter - kidHeights + 1
<< " in line.\nThere are " << maxHeightCount
<< " kids with this height, in total." << std::endl;
}
I2luY2x1ZGUgPGFsZ29yaXRobT4KI2luY2x1ZGUgPGlvc3RyZWFtPgoKaW50IG1haW4oKQp7CiAgICBjb25zdCBpbnQgaGVpZ2h0Q291bnQgPSA4OwogICAgaW50IGtpZEhlaWdodHNbaGVpZ2h0Q291bnRdID0geyAxLCAzLCA2LCA1LCA2LCA0LCAyLCAzIH07CgogICAgLy8geW91ciBmaXJzdCBmb3IgbG9vcAogICAgYXV0byBtYXhIZWlnaHRJdGVyID0gc3RkOjptYXhfZWxlbWVudChraWRIZWlnaHRzLCBraWRIZWlnaHRzICsgaGVpZ2h0Q291bnQpOwoKICAgIC8vIHlvdXIgc2Vjb25kIGZvciBsb29wCiAgICBhdXRvIG1heEhlaWdodENvdW50ID0gc3RkOjpjb3VudChraWRIZWlnaHRzLCBraWRIZWlnaHRzICsgaGVpZ2h0Q291bnQsICptYXhIZWlnaHRJdGVyKTsKCiAgICBzdGQ6OmNvdXQKICAgICAgICA8PCAiSGlnaGVzdCBraWQgaXMgIiA8PCAqbWF4SGVpZ2h0SXRlcgogICAgICAgIDw8ICIgdW5pdChzKSBoaWdoIGFuZCBudW1iZXIgIiA8PCBtYXhIZWlnaHRJdGVyIC0ga2lkSGVpZ2h0cyArIDEKICAgICAgICA8PCAiIGluIGxpbmUuXG5UaGVyZSBhcmUgIiA8PCBtYXhIZWlnaHRDb3VudAogICAgICAgIDw8ICIga2lkcyB3aXRoIHRoaXMgaGVpZ2h0LCBpbiB0b3RhbC4iIDw8IHN0ZDo6ZW5kbDsKfQ==