C two-bucket: final version + separate main

This commit is contained in:
2021-09-08 14:10:05 +02:00
parent 3a3d50b0a5
commit 10f4f8572d
2 changed files with 71 additions and 136 deletions

26
c/two-bucket/main.c Normal file
View File

@@ -0,0 +1,26 @@
/* Standalone tests.
* See GNUmakefile below for explanation
* https://github.com/braoult/exercism/blob/master/c/templates/GNUmakefile
*/
#include "two_bucket.h"
#ifdef UNIT_TEST
int main(int ac, char **av)
{
int arg=1;
int b1, b2, goal, start;
bucket_result_t res;;
for (; arg<ac-3; arg+=4) {
b1 = atoi(av[arg]);
b2 = atoi(av[arg+1]);
goal = atoi(av[arg+2]);
start = atoi(av[arg+3]);
printf("b1=%d, b2=%d, goal=%d, start=%d\n", b1, b2, goal, start);
res = measure(b1, b2, goal, start);
printf(" pos=%d count=%d goal=%d liters=%d\n",
res.possible, res.move_count, res.goal_bucket,
##res.other_bucket_liters);
}
}
#endif