I am trying to find the minimal element of a vector in C ++. I want to return both the value of the lowest element and the position of the index inside the vector. Here is what I tried
auto minIt = std::min_element(vec.begin(), vec.end());
auto minElement = *minIt;
std::cout << "\nMinIT " << &minIt << " while minElement is " << minElement << "\n";
This returns the following
MinIT 8152610 while minElement is 8152610
How to get index i vec (i) where is the value?
source
share