diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main/uknapsack.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/main/uknapsack.c b/src/main/uknapsack.c index e7f3055..1c66430 100644 --- a/src/main/uknapsack.c +++ b/src/main/uknapsack.c @@ -2,6 +2,7 @@ #include <time.h> #include <stdlib.h> #include <string.h> +#include <sys/time.h> #include "common.h" #include "structs.h" #include "dfs.h" @@ -20,8 +21,12 @@ int main(int argc, char * argv[]){ data = input(argv[3]); + /* Seed Random Generator */ + struct timeval tv; + gettimeofday(&tv,NULL); + srand(tv.tv_sec + tv.tv_usec); + /* Sort data */ - srand(time(NULL)); if(strcmp(argv[2], "random") == 0) { qsort(data->items, data->N, sizeof(struct item), cmp_items_random); } else if(strcmp(argv[2], "ratio") == 0) { |