Answers for "how to get the index of biggest in an vector c++"

C++
2

find largest number in vector c++

#include <algorithm> // max_element
#include <vector> 
#include <iostream> // cout 
using namespace std;
int main(){
  vector<int> v1{ 10, 20, 30, 40, 50, 25, 15 };
  cout << *max_element(v1.begin(), v1.end());
}
Posted by: Guest on December-18-2021
1

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

Code answers related to "how to get the index of biggest in an vector c++"

Browse Popular Code Answers by Language