Finding the position of the max element

后端 未结 5 1850
感情败类
感情败类 2020-12-04 11:15

Is there a standard function that returns the position(not value) of the max element of an array of values?

For example:

Suppose I have an array like this:

5条回答
  •  一生所求
    2020-12-04 11:50

    Or, written in one line:

    std::cout << std::distance(sampleArray.begin(),std::max_element(sampleArray.begin(), sampleArray.end()));
    

提交回复
热议问题