10390: STL 函数使用 —— max()
[Creator : ]
Description
【介绍】
【头文件】
Standard Template Library: Algorithms#include<algorithm>
【作用】
Returns the largest of a and b. If both are equivalent, a is returned.default (1) template <class T> constexpr const T& max (const T& a, const T& b); custom (2) template <class T, class Compare> constexpr const T& max (const T& a, const T& b, Compare comp); initializer list (3) template <class T> constexpr T max (initializer_list<T> il); template <class T, class Compare> constexpr T max (initializer_list<T> il, Compare comp);
注意:
$a,b$ 必须是相同的数据类型即可。任何数据类型都可以,只要是相同类型。
如果 $a,b$ 的数据类型不同,比如 int a; long long b; 都会导致编译错误。
【任务】
下面,我们使用 max() 函数,获得最大值。Input
一行包括两个整数 $a,b\ (−10^9≤a,b≤10^9)$,整数之间用空格隔开。
Output
一行包括一个整数,表示答案。
Sample 1 Input
3 5
Sample 1 Output
5
Sample 2 Input
10000 -2983
Sample 2 Output
10000
Sample 3 Input
109 109
Sample 3 Output
109
-50 -50
-50