Answers for "get min and max element index from vector c++"

C++
0

get min and max element index from vector c++

int maxElementIndex = std::max_element(v.begin(),v.end()) - v.begin();
int maxElement = *std::max_element(v.begin(), v.end());

int minElementIndex = std::min_element(v.begin(),v.end()) - v.begin();
int minElement = *std::min_element(v.begin(), v.end());
Posted by: Guest on September-15-2020
0

c++ max and min of vector

template <typename T, size_t N> const T* mybegin(const T (&a)[N]) { return a; }    
template <typename T, size_t N> const T* myend  (const T (&a)[N]) { return a+N; }
Posted by: Guest on July-20-2020

Code answers related to "get min and max element index from vector c++"

Browse Popular Code Answers by Language