To get the position, use std::distance to get the "distance" between the return value of max_element, and &a[0].
The max_element will return a pointer to the largest element, so all you need to do is get the distance between that pointer and the beginning of the a[] array.
The "greatest idea" is to use max_element. There is no need for if() statements.
Something tells me that this is a pre-STL exercise.
“for” loop, may be?
Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
Convenience and productivity tools for Microsoft Visual Studio: FeinViewer - an integrated GDI objects viewer for Visual C++ Debugger, and more...
Bookmarks