Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

Max element in an array with the index in 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;
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #Max #element #array #index
ADD COMMENT
Topic
Name
8+5 =