سلام دوستان این کد برنامه maze رو به صورت خیلی معمولی چاپ می کنه.می خواستم ببینم می تونید کمک کنید که خونه هایی که پیدا می کنه اندیسش رو بریزه تویه پشته و در آخر کوتاه ترین مسیر رو از پشته پاپ کنه؟؟؟
ممنون میشم اگه کمکم کنید.
#include <iostream.h>
#include <conio.h>
//using namespace std;
int col = 1;
int row = 2;
const int ROWMAX = 11;
const int COLMAX = 16;
char maze[ROWMAX][COLMAX] =
{
{'B','B','B','B','B','B','B','B','B','B','B','B',' B','B','B','B'},
{'B','M',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','B'},
{'B','B','B','B','B','B','B','B','B','B',' ','B','B','B',' ','B'},
{'B','W',' ',' ',' ',' ',' ',' ',' ','B',' ','B',' ','B',' ','B'},
{'B','B','B','B','B','B','B','B',' ','B','B','B',' ','B',' ','B'},
{'B',' ',' ',' ',' ',' ',' ','B',' ',' ',' ',' ',' ','B',' ','B'},
{'B','B','B','B','B','B','B','B',' ','B','B','B','B','B',' ','B'},
{'B',' ',' ',' ','B',' ',' ',' ',' ','B',' ',' ',' ',' ',' ','B'},
{'B',' ',' ',' ',' ',' ',' ',' ','B','B','B','B',' ','B','B','B'},
{'B',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','B'},
{'B','B','B','B','B','B','B','B','B','B','B','B',' B','B','B','B'}
};
void printMaze();
void runMaze(int, int);
void printMaze()
{
for(int row = 0; row < ROWMAX; row++)
{
for(int col=0; col < COLMAX; col++)
cout << maze[row][col];
cout << "\n";
}
}
void runMaze(int row, int col)
{
if( (row>0 && row<ROWMAX) && (col>0 && col<COLMAX))
{
if( maze[row][col] == 'W' ) return;
if( maze[row][col] == ' ')
{
maze[row][col]='*';
runMaze(row, col+1);
runMaze(row, col-1);
runMaze(row-1, col);
runMaze(row+1, col);
}
}
}
int main()
{
clrscr();
cout << "Maze before solution:\n";
printMaze();
cout << "Maze after solution:\n";
runMaze(1, 2);
printMaze();
getch();
return 0;
}