From 054a3a47dd5abcfe709a913b90c5ab77c77e750c Mon Sep 17 00:00:00 2001 From: Joe Lukas Kalb Date: Tue, 6 Feb 2024 19:46:05 +0100 Subject: [PATCH] final piece of cake in labyrinth --- src/main/c/labyrinth.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/main/c/labyrinth.c b/src/main/c/labyrinth.c index a83f54d..221e0f7 100644 --- a/src/main/c/labyrinth.c +++ b/src/main/c/labyrinth.c @@ -161,8 +161,28 @@ short calculate_lab_way(Field_State** field, unsigned short len_x, unsigned shor void labyrinth(){ unsigned short len_x, len_y; + Field_State **f; ask_lab_dimensions(&len_x, &len_y); + f = malloc(len_x * sizeof *f); + for (int c_index = 0; c_index < len_x; c_index++){ + f[c_index] = malloc(len_y * sizeof f[c_index]); + } + + ask_lab_walls(f, len_x, len_y); + + if (calculate_lab_way(f, len_x, len_y, 0, 0) == 1){ + printf("Keine Loesung moeglich!\n"); + } + + show_solution(f, len_x, len_y); + + for (int c_index = 0; c_index < len_x; c_index++) + { + free(f[c_index]); + } + free(f); + }