All pastes #1773979 Raw Edit

Anonymous

public text v1 · immutable
#1773979 ·published 2010-02-01 04:10 UTC
rendered paste body
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

void giveBirth(long long &male, long long &female)
{
    bool isMale = rand() % 2;
    if (isMale)
    {
        male++;
        return;
    }
    else
    {
        female++;
        giveBirth(male, female);
    }
}

int main()
{
    srand(time(NULL));
    long long nMale, nFemale;
    for (int i = 0; i < 100; i++)
        giveBirth(nMale, nFemale);

    std::cout << "Male = " << nMale << "\nFemale = " << nFemale << std::endl;
    if (nMale > nFemale)
        std::cout << "More males" << std::endl;
    else
        std::cout << "More females" << std::endl;

    return 0;
}