|
|
@ -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; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |