📅  最后修改于: 2023-12-03 15:13:54.697000             🧑  作者: Mango
C++ min is a standard library function in C++ that is used to find the minimum of two values. The function returns the smaller of the two arguments passed to it.
The syntax for C++ min function is as follows:
template <class T>
const T& min ( const T& a, const T& b );
The C++ min function takes two arguments:
Both arguments have to be of the same type, or atleast the first argument has to be implicitly convertible to the type of the second argument.
C++ min function returns the smaller of the two arguments passed to it.
Here's an example of how to use the C++ min function:
#include <iostream>
#include <algorithm>
int main() {
int a = 10, b = 20;
int result = std::min(a, b);
std::cout << "Minimum value between " << a << " and " << b << " is " << result << std::endl;
return 0;
}
Output:
Minimum value between 10 and 20 is 10
C++ min function is a handy utility function for finding the minimum of two values. It's easy to use and can make your code more readable and efficient.