minmax() in C++

minmax(): This function is a build-in function in STL. This function is available in the file stl_algo.h. This function returns a pair with the smallest of a and b as the first element and the largest as the second. If both are equivalent, the function returns make_pair(a,b).

Syntax:

std::pair<const _Tp &, const _Tp &> std::minmax(const _Tp &__a, const _Tp &__b)

Approach

C++

#include <bits/stdc++.h>
using namespace std;

int main()
{

    pair<intintp = minmax({32324525});

    cout << p.first << " " << p.second << "\n";

    return 0;
}


No comments:

Post a Comment