Finding the Maximum and Minimum Values in a Container Using the min_element algorithm - C++ STL Algorithm

C++ examples for STL Algorithm:min_element

Description

Finding the Maximum and Minimum Values in a Container Using the min_element algorithm

Demo Code

#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main(int argc, char* argv[])
{
    vector<int> myVector{ 4, 10, 6, 9, 1 };
    auto minimum = min_element(myVector.begin(), myVector.end());

    cout << "Minimum value: " << *minimum << std::endl;

    return 0;//  w w  w . j  av  a  2s  .co m
}

Result


Related Tutorials