This commit is contained in:
Valér Jakubčo 2022-01-22 02:27:27 +01:00
parent 7dbf43f175
commit 5b36a493b0
3 changed files with 9 additions and 7 deletions

View File

@ -1,4 +1,4 @@
#define SZ 5 #define SZ 2
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "maze.h" #include "maze.h"
@ -14,11 +14,8 @@ void print_solution(char* matrix,int sz){
int main(){ int main(){
char tmaze[SZ+1][SZ+1]={ char tmaze[SZ+1][SZ+1]={
"*x ", "* ",
" x ", " "
" x ",
" x ",
" ",
}; };
char maze[SZ*SZ]; char maze[SZ*SZ];
memset(maze,' ',SZ*SZ); memset(maze,' ',SZ*SZ);

View File

@ -5,7 +5,7 @@
#include <math.h> #include <math.h>
int paths(char* maze, int journey, int size){ int paths(char* maze, int journey, int size){
//printf("journy je:%d\n",journey); printf("journy je:%d\n",journey);
if(journey == size*size-1){ if(journey == size*size-1){
maze[journey]= '*'; maze[journey]= '*';
@ -18,6 +18,7 @@ int paths(char* maze, int journey, int size){
//Pohyb dole //Pohyb dole
if(journey < (size * size) - (size)){ if(journey < (size * size) - (size)){
puts("dole");
if(paths(maze, journey+size, size)){ if(paths(maze, journey+size, size)){
return 1; return 1;
} }
@ -26,6 +27,7 @@ int paths(char* maze, int journey, int size){
//Pohyb vpravo //Pohyb vpravo
if((journey+1)%size!=0) { if((journey+1)%size!=0) {
puts("vpravo");
if (paths(maze, journey + 1, size)) { if (paths(maze, journey + 1, size)) {
return 1; return 1;
} }
@ -38,6 +40,7 @@ int paths(char* maze, int journey, int size){
//Pohyb vlavo //Pohyb vlavo
if((journey%size)!=0){ if((journey%size)!=0){
puts("vlavo");
if(paths(maze, journey-1, size)) if(paths(maze, journey-1, size))
return 1; return 1;
} }

View File

@ -19,4 +19,6 @@
int solve_maze(char* maze,int size); int solve_maze(char* maze,int size);
int findWay(char* maze, int i, int j);
#endif #endif