dimanche 18 mars 2018

C++ - Randomly selecting 2 integers not in a range?

I'm new to C++, and I've been searching all day to find a way using rand to randomly select 2 integers that are not in a range (ie, select between 1 and 3, without outputting 2)

I've found all sorts of rand expressions, the one I've been using elsewhere in the program is

int c;
int Min = 1;
int Max = 3;
c = rand() % (Max + 1 - Min) + Min;

but I haven't found a way to edit this so i only get 1 or 3, nor have I been able to pull anything I can understand to use a different way of outputting only 1 or 3.

Please help!




Aucun commentaire:

Enregistrer un commentaire