一孩半政,又称独女户二胎,即中国大陆部分农村的一项计划生育政策,第一胎是女孩的夫妻可生育第二个子女。试问这个政策会不会影响男女平衡.
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
using namespace std;
int main()
{
int i, boys = 0, girls = 0;
int n;
cin >> n;
srand((unsigned)time(NULL));
for (i = 0;i < 1000000;i++)
{
if (rand() % 2 == 1)
{
boys++;
}
else
{
girls++;
if (rand() % 100 < n)
{
boys++;
}
else {
if (rand() % 2 == 1)
{
boys++;
}
else
{
girls++;
}
}
}
}
printf("%.2lf", (float)boys / girls);
return 0;
}