#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
using namespace std;
int main()
{
vector<bool> vectorObject;
int i;
for(i = 0; i < 10; i++) {
if(rand() % 2)
vectorObject.push_back(true);
else
vectorObject.push_back(false);
}
cout << "Sequence:\n";
for(i = 0; i <vectorObject.size(); i++)
cout << boolalpha << vectorObject[i] << " ";
cout << endl;
i = count(vectorObject.begin(), vectorObject.end(), true);
cout << i << " elements are true.\n";
return 0;
}
|