Answers for "how to find index of maximum element in vector c++"

C++
0

position of max element in vector c++

int main(int argc, char** argv) {
  int A[4] = {0, 2, 3, 1};
  const int N = sizeof(A) / sizeof(int);

  cout << "Index of max element: "
       << distance(A, max_element(A, A + N))
       << endl;

  return 0;
}
Posted by: Guest on July-08-2021
0

return the index where maximum element in a vector

// my linkedin : https://www.linkedin.com/in/vaalarivan-prasanna-3a07bb203/
cout << distance(vec.begin(), max_element(vec.begin(), vec.end()));
Posted by: Guest on April-29-2021

Code answers related to "how to find index of maximum element in vector c++"

Browse Popular Code Answers by Language