#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
using namespace std;
bool greater9( int );
int main()
{
const int SIZE = 10;
int a1[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
vector< int > v( a1, a1 + SIZE );
random_shuffle( v.begin(), v.end() );
int a2[] = { 100, 2, 8, 1, 50, 3, 8, 8, 9, 10 };
vector< int > v2( a2, a2 + SIZE );
int result = count_if( v2.begin(), v2.end(), greater9 );
cout << "\nNumber of elements greater than 9: " << result;
return 0;
}
bool greater9( int value ) { return value > 9; }
|