According to the following code which can generate random binary numbers, how I can decrease these two for-loops to one for-loop?
Code:
#include <iostream>
#include <string>
#include <ctime>
#include <vector>
using namespace std;
int main()
{
std::vector<int> b;
srand(time(0));
for (int i = 1; i <= 11; i++)
{
b.push_back(i);
}
for (int i = 1; i <= b.size(); i++)
{
b[i] = rand() % 2;
std::cout << b[i] % 2 << " ";
}
}