usaa21/sk1a/maze.c
2022-01-03 15:54:09 +01:00

26 lines
628 B
C

#include <stdio.h>
#include <string.h>
#include "maze.h"
#include <assert.h>
int solve_maze(char* maze,int size) {
int i = 0;
while(i != size*size-1){
if (maze[i + 1] == ' ' && i != size - 1) {
maze[i + 1] = '*';
i++;
} else if (maze[i + size] == ' ' && i != size - 1) {
maze[i + size] = '*';
i = i + size;
} else if (maze[i - 1] == ' ' && i != 0) {
maze[i - 1] = '*';
i--;
} else if (maze[i - size] == ' ' && i > size) {
maze[i - size] = '*';
i = i - size;
}
}
return 1;
}