Mega Code Archive
Use the generic count algorithm with predicate
#include
#include
#include
#include
using namespace std;
int main()
{
int a[] = {0, 0, 0, 1, 1, 1, 2, 2, 2};
int final_count = count_if(&a[0], &a[9], bind2nd(not_equal_to(), 1));
cout << final_count << endl;
return 0;
}
6