update
This commit is contained in:
parent
a1d41ba187
commit
ca9ded8e10
12
sk1a/main.c
12
sk1a/main.c
@ -1,4 +1,4 @@
|
|||||||
#define SZ 2
|
#define SZ 10
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "maze.h"
|
#include "maze.h"
|
||||||
@ -15,7 +15,15 @@ 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 xx ",
|
||||||
|
" xxx ",
|
||||||
|
" x x ",
|
||||||
|
" x x",
|
||||||
|
"xxxxxxx ",
|
||||||
|
" ",
|
||||||
|
"x xxxxxxxx",
|
||||||
|
" xx ",
|
||||||
|
" xx "
|
||||||
};
|
};
|
||||||
char maze[SZ*SZ];
|
char maze[SZ*SZ];
|
||||||
memset(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>
|
#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("index: %d\n",journey);
|
||||||
|
|
||||||
if(journey == size*size-1){
|
if(journey == size*size-1){
|
||||||
maze[journey]= '*';
|
maze[journey]= '*';
|
||||||
@ -18,7 +18,6 @@ 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;
|
||||||
}
|
}
|
||||||
@ -27,7 +26,6 @@ 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;
|
||||||
}
|
}
|
||||||
@ -37,14 +35,13 @@ int paths(char* maze, int journey, int size){
|
|||||||
if(paths(maze, journey-size, size)){
|
if(paths(maze, journey-size, size)){
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
//Pohyb vlavo
|
//Pohyb vlavo
|
||||||
if((journey%size)!=0){
|
if((size%journey)!=0){
|
||||||
puts("vlavo");
|
|
||||||
if(paths(maze, journey-1, size))
|
if(paths(maze, journey-1, size))
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
maze[journey] = ' ';
|
maze[journey] = ' ';
|
||||||
return 0;
|
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