Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

cananybody modify this below maze game program in c++ with pointersand recursion

ID: 3609834 • Letter: C

Question

cananybody modify this below maze game program in c++ with pointersand recursion concepts.
Also if possible can anybody program atic-tac-toe game using pointers


#include <iostream>
using namespace std;

int col = 1;
int row = 2;
const ROWMAX = 11;
const 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(char[]);
void runMaze(char *, int, int);

int main()
{
char * pt = new char;
pt = &maze[ROWMAX + 1][COLMAX + 1];

cout << "Maze before solution: ";
printMaze(pt);
cout << "Maze after solution: ";
runMaze(pt, 1, 2);
delete pt;
return 0;
}
void printMaze(char[])
{
for(int row = 1; row <= ROWMAX; row++)
{
for(int col=1; col <= COLMAX; col++)
cout << maze[row][col];
cout << " ";
}
}
void runMaze(char * ptmaze, int row, int col)
{
if(1 <= row && row <= ROWMAX && 1 <= col&& col <= COLMAX)
{
if(' ' == maze[row][col])
{
maze[row][col] = '*';
if(row == 1 || row == ROWMAX || col == 1 || col == COLMAX)
printMaze(ptmaze);

else
{
runMaze(ptmaze, row - 1, col);
runMaze(ptmaze, row, col + 1);
runMaze(ptmaze, row + 1, col);
runMaze(ptmaze, row, col - 1);
}
}
}
}
cananybody modify this below maze game program in c++ with pointersand recursion concepts.
Also if possible can anybody program atic-tac-toe game using pointers


#include <iostream>
using namespace std;

int col = 1;
int row = 2;
const ROWMAX = 11;
const 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(char[]);
void runMaze(char *, int, int);

int main()
{
char * pt = new char;
pt = &maze[ROWMAX + 1][COLMAX + 1];

cout << "Maze before solution: ";
printMaze(pt);
cout << "Maze after solution: ";
runMaze(pt, 1, 2);
delete pt;
return 0;
}
void printMaze(char[])
{
for(int row = 1; row <= ROWMAX; row++)
{
for(int col=1; col <= COLMAX; col++)
cout << maze[row][col];
cout << " ";
}
}
void runMaze(char * ptmaze, int row, int col)
{
if(1 <= row && row <= ROWMAX && 1 <= col&& col <= COLMAX)
{
if(' ' == maze[row][col])
{
maze[row][col] = '*';
if(row == 1 || row == ROWMAX || col == 1 || col == COLMAX)
printMaze(ptmaze);

else
{
runMaze(ptmaze, row - 1, col);
runMaze(ptmaze, row, col + 1);
runMaze(ptmaze, row + 1, col);
runMaze(ptmaze, row, col - 1);
}
}
}
}

Explanation / Answer

cananybody modify this below maze game program in c++ with pointersand recursion

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote