📄 count.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> > <a href= "index.html">C++ Algorithms</a> > <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 <algorithm> size_t count( iterator start, iterator end, const <a href="../containers.html">TYPE</a>& 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<int> v; for( int i = 0; i < 10; i++ ) { v.push_back( i ); } int target_value = 3; int num_items = count( v.begin(), v.end(), target_value ); cout << "v contains " << num_items << " items matching " << target_value << 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 + -