⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 max_element.html

📁 从www.CppReference.com打包的C++参考手册
💻 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_element</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> &gt; <a href=    "index.html">C++ Algorithms</a> &gt; <a href=    "max_element.html">max_element</a>  </div>  <div class="name-format">    max_element  </div>  <div class="syntax-name-format">    Syntax:  </div>  <pre class="syntax-box">  #include &lt;algorithm&gt;  iterator max_element( iterator start, iterator end );  iterator max_element( iterator start, iterator end, BinPred p );</pre>  <p>The max_element() function returns an iterator to the largest  element in the range [<em>start</em>,<em>end</em>).</p>  <p>If the binary predicate <em>p</em> is given, then it will be used  instead of the &lt; operator to determine the largest element.</p>  <div class="related-examples-format">    Example code:  </div>  <div class="related-examples">    <p>For example, the following code uses the max_element() function    to determine the largest integer in an array and the largest    character in a vector of characters:</p>    <pre class="example-code"> int array[] = { 3, 1, 4, 1, 5, 9 }; unsigned int array_size = 6; cout &lt;&lt; &quot;Max element in array is &quot; &lt;&lt; *max_element( array, array+array_size) &lt;&lt; endl;               vector&lt;char&gt; v; v.push_back(&#39;a&#39;); v.push_back(&#39;b&#39;); v.push_back(&#39;c&#39;); v.push_back(&#39;d&#39;); cout &lt;&lt; &quot;Max element in the vector v is &quot; &lt;&lt; *max_element( v.begin(), v.end() ) &lt;&lt; endl;           </pre>    <p>When run, the above code displays this output:</p>    <pre class="example-code"> Max element in array is 9 Max element in the vector v is d               </pre>  </div>  <div class="related-name-format">    Related topics:  </div>  <div class="related-content">    <a href="max.html">max</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 + -