#include <iostream>
#include <stdlib.h>
#include <time.h>
int main()
{
srand(time(NULL)); //initialize the random seed
while (true) {
const char arrayNum[4] = { '1', '3', '7', '9' };
int RandIndex = rand() % 4; //generates a random number between 0 and 3
cout << arrayNum[RandIndex];
}
}
When generating this numbers some of them are repeating and i don't want this.Is a way for this?
Aucun commentaire:
Enregistrer un commentaire