I have been given the assignment to create a non-repeating number generator, which generates 7 numbers. I have used the rand function. But not sure how to make sure the numbers are not repetitive. Thanks for the help
int i, n;
time_t t;
n = 7;
srand((unsigned) time(&t));
for( i = 0 ; i < n ; i++ ) {
printf("%d\t", rand() % 35);}
Aucun commentaire:
Enregistrer un commentaire