Browse Source

if anweisung nach rechts hinzugefügt

remotes/origin/Labyrinth
Ronja Awe 2 years ago
parent
commit
df3ed5c1b2
  1. 3
      src/c/labyrinth.c
  2. 19
      test/c/test_labyrinth.c

3
src/c/labyrinth.c

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

19
test/c/test_labyrinth.c

@ -109,6 +109,25 @@ void test_LabyrinthUnten(void){
TEST_ASSERT_EQUAL_INT(1, result); TEST_ASSERT_EQUAL_INT(1, result);
}
void test_LabyrinthRechts(void){
bool result;
int input = 1;
int hoehe = 3;
int breite = 3;
lab laby = {
{'0', '0', '0'},
{'1', '1', '1'},
{'1', '1', '1'},
};
wegsuchen(laby, &result, 0, 0, 0, 2);
printlabyrinth(laby, hoehe, breite);
TEST_ASSERT_EQUAL_INT(1, result);
} }
#endif // TEST #endif // TEST
Loading…
Cancel
Save