446,420 Members | 1,130 Online
Need help? Post your question and get tips & solutions from a community of 446,420 IT Pros & Developers. It's quick & easy.

# Problem writing in the trail of matrix of maze program

 P: 1 Hi im an IT student.I have registered as a member of this site recently.I have a question about the solution of maze program. I want to write maze program in c++ .I want to solve the maze class includes two methods: 1)makeMaze & 2)runMaze. I write the method of makeMaze in a way that fulls a n*n matrix. one of my problem is about the writing the code of dynamic 2D array allocation . an another is about the writing the method of runMaze in a way that finds the path for movment and then print this in a trail of matrix and as we know the "main" is necessary to write it. I saw the maze program that you have written in the part of "c++ maze program" but the code of that post dosent follow the path of movment in a trail of matrix. here is the code: #include #include #include class maze { int a[100][100]; public: void makeMaze(); void runMaze(int row, int col); }; //************************************************** * void maze :: makeMaze() { clrscr(); srand(time(0)); int maze[10][10]={0}; int i,j=0; for( i=0;i<10;i++) for(j=0;j<10;j++) maze[i][j] =random(2); for( i=0;i<10;i++){ for(j=0;j<10;j++) cout<0 && row<10) && (col>0 && col<10)) { if( a[row][col] == 'W' ) return; if( a[row][col] == ' ') { a[row][col]='*'; runMaze(row, col+1); runMaze(row, col-1); runMaze(row-1, col); runMaze(row+1, col); } } } //************************************************** ***** int main() { clrscr(); maze m; m.makeMaze(); m.runMaze(1, 2); getch(); return 0; } Im in a hurry. please help me to solve this qustion very soon. thank you Jun 4 '07 #1