lundi 7 juin 2021

Arithmetically random picking values, like from specific list

Can I somehow implement random picking values from specific list without using an array?

I can do this:

list_of_values = { 20, 40, 60, 80, 100, ..., 440 };
random_pick = list_of_values[rand() % list_of_values.size()];

But I'd like to do it without the list, just arithmetically.

Aucun commentaire:

Enregistrer un commentaire