Added timer for bests solutions

This commit is contained in:
2021-01-23 19:20:21 +01:00
parent 1b43433420
commit e1c734cb63
6 changed files with 123 additions and 24 deletions

11
lceb.c
View File

@@ -12,6 +12,7 @@
#include <stdarg.h>
#include <malloc.h>
#include <string.h>
#include <locale.h>
#include "lceb.h"
int main(ac, av)
@@ -20,19 +21,20 @@ int main(ac, av)
{
unsigned target;
STACK inputstack, *stack;
int i, j, k, stacksize, val, res;
//char *ops="+-*/", *opscomb;
//int len_ops=strlen(ops), ncombs, nops;
int i, j, k, stacksize, val;
int ncombs, nstacks, ntrees, nops;
TREE *tree;
int intarray[1024];
int eval;
char *comb;
struct timespec end;
setlocale(LC_ALL, ""); /* to use "%'d" in printf */
if (ac < 4 || ac > 2+MAXINPUT) {
fprintf(stderr, "usage: %s target n1 n2 [...n%d]\n", *av, MAXINPUT);
exit(1);
}
start_timer();
target=atoi(av[1]);
stacksize=2*(ac-2)-1;
nops=ac-2-1;
@@ -110,5 +112,8 @@ int main(ac, av)
}
printf("\n");
print_bests();
set_timer(&end);
printf("Total time elapsed: %.5f secs, nodes/leaves evaluated:%'d/%'d\n",
get_timer(end), get_totnodes(), get_totleaves());
exit(0);
}