Browse Source

if Anweisung nach oben hinzugefügt

remotes/origin/Labyrinth
Ronja Awe 2 years ago
parent
commit
07524ab01c
  1. 3
      src/c/labyrinth.c
  2. 18
      test/c/test_labyrinth.c

3
src/c/labyrinth.c

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

18
test/c/test_labyrinth.c

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