vendredi 4 septembre 2015

Random integral numbers from uniform distribution

I have to write a c++ program and have a problem only with the following part:

[...] for that purpose, you will need two random integral numbers from uniform distribution on the set {0,1,...,9} (those two numbers have to be generated with equal probability) [...]

I don't know math as good as c++, also I'm not allowed to use c++11. I've written the following simple code, but I doubt if it's correct? :P

//...
srand(time(0));
int first_number = rand() % 10;
int second_number = rand() % 10;
//...




Aucun commentaire:

Enregistrer un commentaire