update
This commit is contained in:
parent
a1d41ba187
commit
ca9ded8e10
14
sk1a/main.c
14
sk1a/main.c
@ -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);
|
||||
|
BIN
sk1a/main.o
BIN
sk1a/main.o
Binary file not shown.
11
sk1a/maze.c
11
sk1a/maze.c
@ -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;
|
||||
}
|
||||
|
BIN
sk1a/maze.o
BIN
sk1a/maze.o
Binary file not shown.
BIN
sk1a/program
BIN
sk1a/program
Binary file not shown.
Loading…
Reference in New Issue
Block a user