#include #include char buffer[110][110][1000]; int len[1000]; char maze[110][110]; char bestmaze[110][110]; int bufcount=0, stopx, stopy; int steps=0; int startx, starty, beststep=99999, bestindex, width, height; char hei[100]; int wmap[110][110]; void print_maze(FILE *f) { int x, y; for (y=0; y beststep) return; // if (maze[y][x] == 'x') // return; // if (maze[y][x] == '.') // return; if (maze[y][x] == '$') { if (beststep > steps) { beststep = steps; memcpy(bestmaze,maze,110*110); } return; } if ((maze[y][x] == ' ') || ((maze[y][x] == '*') && (steps == 0))) { steps++; maze[y][x] = '.'; if ((maze[y][x+1] == ' ') || (maze[y][x+1] == '$')) traverse(x+1,y); if ((maze[y+1][x] == ' ') || (maze[y+1][x] == '$')) traverse(x,y+1); if ((maze[y][x-1] == ' ') || (maze[y][x-1] == '$')) traverse(x-1,y); if ((maze[y-1][x] == ' ') || (maze[y-1][x] == '$')) traverse(x,y-1); maze[y][x] = ' '; steps--; } } int main(int argc, char **argv) { FILE *fp, *fp2; char temp[] = "maze.in"; int i, count, j; int x, y; char _temp[110]; printf("kjører...\n"); if (!(fp = fopen(temp, "r"))) { printf("kan ikke åpne inputfil.\n"); return 1; } fp2 = fopen("maze.out","w"); fgets(_temp, 110, fp); sscanf(_temp, "%i", &count); memset(len, 0x00, sizeof(len)); for (i=0; i