min of an array in c++ code example
Example: min array c++
*min_element(ForwardIt first, ForwardIt last)
*min_element(ForwardIt first, ForwardIt last, Compare comp)
#include <bits/stdc++.h>
using namespace std;
main() {
vector<int> v{ 3, 1, -14, 6, 5, 9 };
int result;
result = *min_element(v.begin(), v.end());
cout << "min element is: " << result << '\n';
result = *min_element(v.begin(), v.end(), [](int a, int b) { return abs(a)<abs(b); });
cout << "min element (absolute) is: " << result << '\n';
}