std::minmax() and std::minmax_element() in C++ STLWe are already aware that the C++ programming language has a Standard Template Library which is vast like an ocean and has many pre-defined functionalities. To get the answer of which among the array elements passed either as an input by the user or pre-defined by the testers/developers is maximum or minimum amongst them, we use the standard minimum function or the entire function. It might get a little overwriting or using the code, again and again, to know both values at a time. So C++ STL has a solution for us in the form of std minmax() and minmax_element functions. Both functions accept parameters in the form either variables, which are of any natural numbers, integers and also an array of elements. C++ Code for minmax() FunctionOutput: / tmp / 1Lj mBg VyK h.o The minimum value is : 33 The maximum value is : 63 minimum value : 11 maximum value : 16 C++ Code for minmax_element() FunctionOutput: / tmp /1 LjmB gVy Kh.o position of the minimum value obtained after operating is : 7 position of the maximum value received after working is : 10 position of the minimum value obtained after operating is : 1 position of the maximum value received after working is : 5 |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India