usaa21/sk1a/maze.c

65 lines
934 B
C
Raw Normal View History

2022-01-09 00:12:46 +00:00
#include <stdio.h>
#include <string.h>
#include "maze.h"
#include <assert.h>
#include <math.h>
int solve_maze(char* maze, int size){
for(int i = 0; i < size * size; i++){
if(maze[i] == ' '){
maze[i] = '*';
continue;
}else{
i = i+size-2;
continue;
}
}
return 1;
}
/*int solve_maze(char* maze,int size){
char smaze[size+1][size+1];
char* wmaze = smaze;
int k = 0;
memset(smaze, 0, size);
for (int i = 0; i < size; i++) {
for (int j = 0; j < size; j++) {
smaze[i][j] = maze[k];
k++;
}
}
for (int i = 0; i < size; i++) {
for (int j = 0; j < size; j++) {
printf("%c ",smaze[i][j]);
}
printf("\n");
}
int r = findWay(0,0,size);
return r;
}
int findWay(int i, int j, int size){
if(wmaze[i][j] == ' '){
wmaze[i][j] = '*';
if(findWay(i, j+1, size) == 1) return 1;
if(findWay(i+1, j+1, size) == 1) return 1;
wmaze[i][j] = ' ';
}
return 0;
}
*/