diff --git a/src/c/labyrinth.c b/src/c/labyrinth.c index ef4b942..7a7683b 100644 --- a/src/c/labyrinth.c +++ b/src/c/labyrinth.c @@ -20,29 +20,30 @@ int printlabyrinth(lab laby, int hoehe, int breite){ return 0; } + void wegsuchen(lab laby, bool* done, int y, int x, int ziely, int zielx){ laby[y][x] = 'X'; + if(x == zielx && y == ziely){ *done = true; } else{ - if (!*done && y + 1 <= ziely && laby[y+1][x] == '0'){ + if (!*done && y + 1 <= ziely && laby[y+1][x] == WEG){ wegsuchen(laby, done, y + 1, x, ziely, zielx); } - if (!*done && x + 1 <= zielx && laby[y][x+1] == '0'){ + if (!*done && x + 1 <= zielx && laby[y][x+1] == WEG){ wegsuchen(laby, done, y, x + 1, ziely, zielx); } - if (!*done && y - 1 >= 0 && laby[y-1][x] == '0'){ // oben + if (!*done && y - 1 >= 0 && laby[y-1][x] == WEG){ // oben wegsuchen(laby, done, y - 1, x, ziely, zielx); } - if (!*done && x - 1 >= 0 && laby[y][x-1] == '0'){ // links + if (!*done && x - 1 >= 0 && laby[y][x-1] == WEG){ // links wegsuchen(laby, done, y, x - 1, ziely, zielx); } if (!*done){ - laby[y][x] = '0'; + laby[y][x] = WEG; } - } } \ No newline at end of file diff --git a/src/c/labyrinth.h b/src/c/labyrinth.h index 3d71f1e..1ef7b8c 100644 --- a/src/c/labyrinth.h +++ b/src/c/labyrinth.h @@ -5,6 +5,7 @@ #define MAXZEILEN 10 #define MAXSPALTEN 10 +#define WEG '0' typedef char lab[MAXZEILEN][MAXSPALTEN]; int printlabyrinth(lab laby, int hoehe, int breite);