This commit is contained in:
Valér Jakubčo 2022-01-24 00:15:28 +01:00
parent a1d41ba187
commit ca9ded8e10
5 changed files with 15 additions and 10 deletions

View File

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

Binary file not shown.

View File

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

Binary file not shown.

Binary file not shown.