From 0f311fe1f29539de4191351faffae571b5bf68ce Mon Sep 17 00:00:00 2001 From: vj586da Date: Sat, 22 Jan 2022 01:27:59 +0100 Subject: [PATCH] uprava podmienok --- sk1a/maze.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/sk1a/maze.c b/sk1a/maze.c index f481051..a5c966a 100644 --- a/sk1a/maze.c +++ b/sk1a/maze.c @@ -5,26 +5,31 @@ #include int paths(char* maze, int journey, int size){ + //printf("journy je:%d\n",journey); if(journey == size*size-1){ maze[journey]= '*'; return 1; } - if(journey >= 0 && journey <= (size*size) && maze[journey]==' ' && maze[journey]!='*'){ - maze[journey] = '*'; + if(journey >= 0 && journey < (size*size) && maze[journey]==' '){ + + maze[journey] = '*'; //Pohyb dole - if(paths(maze, journey+size, size)){ - return 1; - } + if(journey < (size * size) - (size)){ + if(paths(maze, journey+size, size)){ + return 1; + } + } //Pohyb vpravo - if(paths(maze, journey+1, size)){ - return 1; - } - + if(((journey+1)%size)!=0) { + if (paths(maze, journey + 1, size)) { + return 1; + } + } //Pohyb hore if(paths(maze, journey-size, size)){ @@ -45,4 +50,3 @@ int paths(char* maze, int journey, int size){ int solve_maze(char* maze, int size){ return paths(maze, 0, size); } -