#include #include using namespace std; int main ( ) { //unsigned seed = std::chrono::system_clock::now().time_since_epoch().count(); default_random_engine generator; uniform_int_distribution BoyOrGirl(0,1); uniform_int_distribution DayOfWeek(0,6); unsigned short child[2], birth[2]; unsigned long norm[2] = { 0, 0 }, boys[2] = { 0, 0 }; for ( unsigned long int i = 0; i < 100000000; ++i ) { child[0] = BoyOrGirl(generator); child[1] = BoyOrGirl(generator); birth[0] = DayOfWeek(generator); birth[1] = DayOfWeek(generator); //if ( child[0] == 0 || child[1] == 0 ) //cout << child[0] << "\t" << child[1] << "\t" << birth[0] << "\t" << birth[1] << endl; if ( child[0] == 0 && child[1] == 0 ) { ++norm[0]; ++boys[0]; if ( birth[0] == 2 || birth[1] == 2 ) { ++norm[1]; ++boys[1]; } } if ( child[0] == 1 && child[1] == 1 ) { ; } if ( child[0] == 0 && child[1] == 1 ) { ++norm[0]; if ( birth[0] == 2 ) ++norm[1]; } if ( child[0] == 1 && child[1] == 0 ) { ++norm[0]; if ( birth[1] == 2 ) ++norm[1]; } } cout << double(boys[0])/double(norm[0]) << "\t" << double(boys[1])/double(norm[1]) << endl; return 0; }