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

📄 count.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>count</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="count.html">count</a>  </div>  <div class="name-format">    count  </div>  <div class="syntax-name-format">    Syntax:  </div>  <pre class="syntax-box">  #include &lt;algorithm&gt;  size_t count( iterator start, iterator end, const <a href="../containers.html">TYPE</a>&amp; val );</pre>  <p>The count() function returns the number of elements between  <em>start</em> and <em>end</em> that match <em>val</em>.</p>  <p>For example, the following code uses count() to determine how many  integers in a vector match a target value:</p>  <pre class="example-code"> vector&lt;int&gt; v; for( int i = 0; i &lt; 10; i++ ) {   v.push_back( i ); }               int target_value = 3; int num_items = count( v.begin(), v.end(), target_value );              cout &lt;&lt; &quot;v contains &quot; &lt;&lt; num_items &lt;&lt; &quot; items matching &quot; &lt;&lt; target_value &lt;&lt; endl;            </pre>  <p>The above code displays the following output:</p>  <pre class="example-code"> v contains 1 items matching 3          </pre>  <div class="related-name-format">    Related topics:  </div>  <div class="related-content">    <a href="accumulate.html">accumulate</a><br>    <a href="adjacent_difference.html">adjacent_difference</a><br>    <a href="count_if.html">count_if</a><br>    <a href="inner_product.html">inner_product</a><br>    <a href="partial_sum.html">partial_sum</a>  </div>  </div>  </td>    </tr>  </table></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -