sleepdefic1t
7/3/2018 - 2:37 AM

rand01.hpp

#include <iostream>
#include <random>

int rand01()
{
	std::random_device rd;
	std::mt19937 gen(rd());
	std::uniform_int_distribution<> dis(0, 1);
	return dis(gen);
}

int main()

{
	int zeroCount = 0;
	int oneCount = 0;
	
	for (int i = 0; i < 1000; i++)
	{
		int randBit = rand01();
		if (randBit == 0) { zeroCount++; }
		else { oneCount++; }
	}
	
	std::cout << zeroCount << std::endl;
	std::cout << oneCount << std::endl;
}