Mega Code Archive
Demonstrate count and count_if
#include
#include
#include
using namespace std;
bool even(int x)
{
return !(x%2);
}
int main()
{
vector vectorObject;
int i;
for(i = 0; i <20; i++) {
if(i%2) vectorObject.push_back(1);
else vectorObject.push_back(2);
}
cout << "Sequence: ";
for(i = 0; i