min array c 2b 2b

Solutions on MaxInterview for min array c 2b 2b by the best coders in the world

showing results for - "min array c 2b 2b"
María Alejandra
24 Jun 2017
1//Syntax
2*min_element(ForwardIt first, ForwardIt last)
3*min_element(ForwardIt first, ForwardIt last, Compare comp)
4//Example:
5#include <bits/stdc++.h>
6using namespace std;
7
8main() {
9    vector<int> v{ 3, 1, -14, 6, 5, 9 }; 
10    int result;
11    
12    result = *min_element(v.begin(), v.end());
13    cout << "min element is: " << result << '\n'; //-14
14 
15    result = *min_element(v.begin(), v.end(), [](int a, int b) { return abs(a)<abs(b); });
16    cout << "min element (absolute) is: " << result << '\n'; //1
17}