Finding the position of the max element

后端 未结 5 1851
感情败类
感情败类 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:28

    std::max_element takes two iterators delimiting a sequence and returns an iterator pointing to the maximal element in that sequence. You can additionally pass a predicate to the function that defines the ordering of elements.

提交回复
热议问题