nepomohlo
This commit is contained in:
parent
0f311fe1f2
commit
9c8babdb69
29
sk1a/maze.c
29
sk1a/maze.c
@ -5,7 +5,6 @@
|
||||
#include <math.h>
|
||||
|
||||
int paths(char* maze, int journey, int size){
|
||||
//printf("journy je:%d\n",journey);
|
||||
|
||||
if(journey == size*size-1){
|
||||
maze[journey]= '*';
|
||||
@ -13,23 +12,19 @@ int paths(char* maze, int journey, int size){
|
||||
}
|
||||
|
||||
if(journey >= 0 && journey < (size*size) && maze[journey]==' '){
|
||||
|
||||
maze[journey] = '*';
|
||||
maze[journey] = '*';
|
||||
|
||||
//Pohyb dole
|
||||
if(journey < (size * size) - (size)){
|
||||
if(paths(maze, journey+size, size)){
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
if(paths(maze, journey+size, size)){
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
//Pohyb vpravo
|
||||
if(((journey+1)%size)!=0) {
|
||||
if (paths(maze, journey + 1, size)) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
if(paths(maze, journey+1, size)){
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
//Pohyb hore
|
||||
if(paths(maze, journey-size, size)){
|
||||
@ -37,10 +32,11 @@ int paths(char* maze, int journey, int size){
|
||||
}
|
||||
|
||||
//Pohyb vlavo
|
||||
/* if(paths(maze, journey-1, size))
|
||||
return 1;
|
||||
*/
|
||||
if(size%journey!=0){
|
||||
if(paths(maze, journey-1, size))
|
||||
return 1;
|
||||
|
||||
}
|
||||
maze[journey] = ' ';
|
||||
}
|
||||
|
||||
@ -50,3 +46,4 @@ int paths(char* maze, int journey, int size){
|
||||
int solve_maze(char* maze, int size){
|
||||
return paths(maze, 0, size);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user