문제

Which _STD function(s) return the max, or min of 2 integers, signed or unsigned? Is it the max, min in the math.h header library or what could they be?

도움이 되었습니까?

해결책

std::min and std::max in the <algorithm> library. As they're templates they return the min and max for every type that implements the < operator (or you can supply a functor for your custom comparison).

See Algorithms library (link to cppreference.com).

다른 팁

You can use the new algorithm introduced in C++11(

 template<class T> pair<const T&, const T&> minmax(const T& a, const T& b);

Returns: pair(b, a) if b is smaller than a, and pair(a, b) otherwise.

std::max and std::min are in the file algorithm.

You can look up the other functions included in this file at C++ Reference. Bookmark it for future usage.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top