jeudi 16 février 2017

Is it possible to keep generating random numbers until it satisfies a specific sum??

I have an array of Random numbers and I want to keep changing the array values until it reaches a certain average which I am checking in a loop.

partial code:

numbers[] is na integer array and numbers Random[] is a Random array

while(avg!=avg(numbers)){
   for(...){
     numbers[i] = numbersRandom[i].nextInt((max-min)+1)+min;
   }
}




Aucun commentaire:

Enregistrer un commentaire