sort/src/random.c

13 lines
256 B
C
Raw Normal View History

2018-11-07 14:46:42 -03:00
#include <stdlib.h>
#include <time.h>
static int sort_rand_initialized = 0;
int gen_rand(int min, int max) {
if (sort_rand_initialized == 0) {
srand((unsigned int) time(NULL));
sort_rand_initialized = 1;
}
return rand() % (max + 1 - min) + min;
}