From all families with two children, at least one of whom is a boy, a family is chosen at random. This would yield
the answer of 1/3.
From all families with two children, one child is selected at random, and the sex of that child is specified to be a
boy. This would yield an answer of 1/2.
total = found = 0; for (auto n = 0; n < count; ++n) { auto i = array_index_gen(gen); if (db[i][0] == B || db[i][1] == B) { total++; if (db[i][0] == db[i][1]) { found++; } } }
cout << "found/total: " << found << "/" << total << " = " << found * 100.0/total << endl; }
total = found = 0; for (auto n = 0; n < count; ++n) { auto i = array_index_gen(gen); auto j = sub_index_gen(gen); if (db[i][j] == B) { total++; if (db[i][1-j] == B) { found++; } } }
cout << "found/total: " << found << "/" << total << " = " << found * 100.0/total << endl; }