lundi 5 avril 2021

How do I make a random number generater from 1 to 4 in c++ [duplicate]

I am working on getting different responses for a personal A.I system. We all know how boring it is to get the same response. So I am trying to get different responses. I have a random number generator but it only prints the number one. Here it is. What did I do wrong

int random_integer;
int lowest=1, highest=4;
int range=(highest-lowest)+1;
random_integer = lowest + int(range*rand()/(RAND_MAX + 4.0));



Aucun commentaire:

Enregistrer un commentaire