Check out example codes for "max element in vector c++". It will help you in understanding the concepts better.

Code Example 1

*max_element(a.begin(), a.end());

Code Example 2

*max_element (first_index, last_index);
ex:- for an array arr of size n
*max_element(arr, arr + n);

Code Example 3

auto max = *max_element(vector.begin(), vector.end());

Code Example 4

int main() 
{ 
    // Get the vector 
    vector<int> a = { 1, 45, 54, 71, 76, 12 }; 
  
    // Print the vector 
    cout << "Vector: "; 
    for (int i = 0; i < a.size(); i++) 
        cout << a[i] << " "; 
    cout << endl; 
  
    // Find the max element 
    cout << "\nMax Element = "
         << *max_element(a.begin(), a.end()); 
    return 0; 
}

Code Example 5

// C++ program to demonstrate the use of std::max_element 
#include <iostream> 
#include <algorithm> 
using namespace std; 
int main() 
{ 
    int v[] = { 'a', 'c', 'k', 'd', 'e', 'f', 'h' }; 
  
    // Finding the maximum value between the first and the 
    // fourth element 
  
    int* i1; 
    i1 = std::max_element(v, v + 4); 
  
    cout << char(*i1) << "\n"; 
    return 0; 
}

Code Example 6

*min_element(a.begin(), a.end());

Learn ReactJs, React Native from akashmittal.com