C++ examples for STL Algorithm:min_element
Finding the Maximum and Minimum Values in a Container Using the min_element algorithm
#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 }