📄 max.html
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head> <meta name="generator" content= "HTML Tidy for Linux/x86 (vers 1 September 2005), see www.w3.org"> <title>max</title> <link href="../cppreference.css" rel="stylesheet" type="text/css"></head><body><table> <tr> <td> <div class="body-content"> <div class="header-box"> <a href="../index.html">cppreference.com</a> > <a href= "index.html">C++ Algorithms</a> > <a href="max.html">max</a> </div> <div class="name-format"> max </div> <div class="syntax-name-format"> Syntax: </div> <pre class="syntax-box"> #include <algorithm> const <a href="../containers.html">TYPE</a>& max( const <a href="../containers.html">TYPE</a>& x, const <a href="../containers.html">TYPE</a>& y ); const <a href="../containers.html">TYPE</a>& max( const <a href="../containers.html">TYPE</a>& x, const <a href="../containers.html">TYPE</a>& y, BinPred p );</pre> <p>The max() function returns the greater of <em>x</em> and <em>y</em>.</p> <p>If the binary predicate <em>p</em> is given, then it will be used instead of the < operator to compare the two elements.</p> <div class="related-examples-format"> Example code: </div> <div class="related-examples"> <p>For example, the following code snippet displays various uses of the max() function:</p> <pre class="example-code"> cout << "Max of 1 and 9999 is " << max( 1, 9999) << endl; cout << "Max of 'a' and 'b' is " << max( 'a', 'b') << endl; cout << "Max of 3.14159 and 2.71828 is " << max( 3.14159, 2.71828) << endl; </pre> <p>When run, this code displays:</p> <pre class="example-code"> Max of 1 and 9999 is 9999 Max of 'a' and 'b' is b Max of 3.14159 and 2.71828 is 3.14159 </pre> </div> <div class="related-name-format"> Related topics: </div> <div class="related-content"> <a href="max_element.html">max_element</a><br> <a href="min.html">min</a><br> <a href="min_element.html">min_element</a> </div> </div> </td> </tr> </table></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -