dimanche 27 novembre 2016

How to generate random values with fixed sum in C++

I want to generate 3 random numbers in the range 0 to 9 that sum up to a given fixed number. For example, for the given fixed sum 15, one possible solution would be (3, 8, 4). How can I do this?




Aucun commentaire:

Enregistrer un commentaire