summaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
authorAlexandre Jesus <adbjesus@gmail.com>2016-09-16 09:25:34 +0100
committerAlexandre Jesus <adbjesus@gmail.com>2016-09-16 09:25:34 +0100
commitd3878228d84dd2296cd85d914f27087d3cae2835 (patch)
tree8ed40e3d77fe3cb906baf1414da46c0a168226aa /src/main
parent37f41a284d633babeb152dbc0bf0248058fc25c9 (diff)
downloadlibuknapsack-d3878228d84dd2296cd85d914f27087d3cae2835.tar.gz
libuknapsack-d3878228d84dd2296cd85d914f27087d3cae2835.zip
Add pseudo-random shuffler
Diffstat (limited to 'src/main')
-rw-r--r--src/main/dfs.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/main/dfs.c b/src/main/dfs.c
index ca796c5..f28f8ab 100644
--- a/src/main/dfs.c
+++ b/src/main/dfs.c
@@ -1,5 +1,6 @@
#include <stdio.h>
#include <time.h>
+#include <stdlib.h>
#include "common.h"
#include "structs.h"
#include "dfs.h"
@@ -16,12 +17,16 @@ int main(int argc, char * argv[]){
d = input(argv[1]);
+ /* srand() and qsort data */
+ srand(time(NULL));
+ qsort(d->items, d->N, sizeof(struct item), cmp_items_random);
+
clock_t t = clock();
b = dfs(d);
t = clock() - t;
printf("%f,%d\n",((float)t)/CLOCKS_PER_SEC,len_front(b));
-
+
print_front(b);
free_front(b);