| <<< C++ Standard Library algoritm header | Index | What is array name ? >>> |
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
const int SIZE = 5;
int dummy[ SIZE ] = { 5, 10, 5, 5, 10 };
int cnt = std::count( dummy, dummy + SIZE, 5 );
std::cout
<< "Array has "
<< cnt
<< " values that are equal to 5."
<< '\n'
;
return 0;
}
/*Program output:
Array has 3 values that are equal to 5.
*/
| <<< C++ Standard Library algoritm header | Index | What is array name ? >>> |