position of max

This is a discussion on position of max within the C++ Programming forums, part of the General Programming Boards category; i have written this code to print the position of max in the array.
but how can i find all ...

I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.

Roughly yes, but with slightly better indentation, and declaring main to return an int and including <cstdio> instead of <stdio.h>.

A single pass solution is possible by storing the currently known positions of the currently known maximum in a std::vector or array (i.e., what anon later suggested - I was unable to correct my post earlier due to network problems).

I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.