Use min_element to get the minimum value : min_element « STL Algorithms Min Max « C++ Tutorial






#include <algorithm>
#include <functional>
#include <iomanip>
#include <iostream>
#include <vector>

using namespace std;

int main(){

   const float a[] = { 13.4, 27.6, 15.5, 44.3, 51.2, 30.2, 18.0 };
   vector<float> data( a,a + sizeof( a ) / sizeof( a[0] ) );

   float data_min = *min_element( data.begin(), data.end() );
   
   cout << data_min;
}








29.4.min_element
29.4.1.Find and print minimum elements in a vector
29.4.2.Use min_element to get the minimum element in a container
29.4.3.Use min_element to get the minimum value
29.4.4.Use min_element with criteria function