jeudi 21 mai 2015

C programming generate 2 and 4 with a percentage

int random;
random=rand();

        if(random<90)
        var[x][y]=2;
        else 
        var[x][y]=4;

How can I generate 2 at a percentage of 90% and 4 at 10 %?




Aucun commentaire:

Enregistrer un commentaire