This question already has an answer here:
int runTrials(int array[], int size, int trials){
int c = 0;
for(int i = 0; i < trials; i++){
srand(time(0));
randomize(array,size); //initialize values
bool existSame = checkSame(array, size);
if (existSame == true){
c+=1;
}
}
return c;
}
void randomize(int array[], int size){
int daysOfYear = 365;
for(int i = 0; i < size ; i++){
array[i] = rand() % daysOfYear;
}
}
I am trying to generate a different set of random numbers, but it is still generating the same set of numbers even though I already used srand()
and time(0)
.
Aucun commentaire:
Enregistrer un commentaire