Browse Source

if Anweisung nach links hinzugefügt

remotes/origin/Labyrinth
Ronja Awe 2 years ago
parent
commit
c485a3c87b
  1. 4
      src/c/labyrinth.c
  2. 4
      src/c/labyrinth.h
  3. 20
      test/c/test_labyrinth.c

4
src/c/labyrinth.c

@ -37,5 +37,9 @@ void wegsuchen(lab laby, bool* done, int y, int x, int ziely, int zielx){
if (!*done && y - 1 >= 0 && laby[y-1][x] == '0'){ // oben
wegsuchen(laby, done, y - 1, x, ziely, zielx);
}
if (!*done && x - 1 >= 0 && laby[y][x-1] == '0'){ // links
wegsuchen(laby, done, y, x - 1, ziely, zielx);
}
}
}

4
src/c/labyrinth.h

@ -3,8 +3,8 @@
#include <stdbool.h>
#define MAXZEILEN 5
#define MAXSPALTEN 5
#define MAXZEILEN 10
#define MAXSPALTEN 10
typedef char lab[MAXZEILEN][MAXSPALTEN];
int printlabyrinth(lab laby, int hoehe, int breite);

20
test/c/test_labyrinth.c

@ -148,4 +148,24 @@ void test_LabyrinthOben(void){
TEST_ASSERT_EQUAL_INT(1, result);
}
void test_LabyrinthLinks(void){
bool result;
int input = 1;
int hoehe = 5;
int breite = 6;
lab laby = {
{'0', '1', '0', '0', '0', '0'},
{'0', '1', '0', '1', '1', '0'},
{'0', '1', '0', '0', '1', '0'},
{'0', '1', '1', '0', '1', '0'},
{'0', '0', '0', '0', '1', '0'},
};
wegsuchen(laby, &result, 0, 0, 4, 5);
printlabyrinth(laby, hoehe, breite);
TEST_ASSERT_EQUAL_INT(1, result);
}
#endif // TEST
Loading…
Cancel
Save