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

This is a sample maze that my professor has given me. The final objective of my

ID: 3620059 • Letter: T

Question

This is a sample maze that my professor has given me. The final objective of my code is to traverse this maze but the problem I'm having is finding the entrance and correctly labeling it. The entrance and exit are defined as a '0' on the outer edges of the maze. There are always only two '0's on the outer edge. Our professor wants us to work in a couter-clockwise fashion around the maze starting at position array[0][0]. The first '0' found is meant to be the entrance witht he second '0' being the exit. For some reason my code is not jumping out of the while loop when it finds the first '0' and is simply saying the second '0' is the exit. My code is posted below. Any help would be appreciated.

void findentrance(void)/*Finds the entrance and exit of the maze*/
{

int j;
int count = 0;

while(count != 1){

/*Checks the left side of the maze for an entrance*/
for(j=0; j<=M-1; j++)
{
if(array[j][0] == '0')
entranceM = j;
entranceN = 0;
count = 1;
}

/*Checks the bottom side of the maze for an entrance*/
for(j=0; j<=N-1; j++)
{
if(array[M-1][j] == '0')
entranceM = M-1;
entranceN = j;
count = 1;
}

/*Checks the right side of the maze for an entrance*/
for(j=N-1; j>=0; j--)
{
if(array[j][N-1] == '0')
entranceM = j;
entranceN = N-1;
count = 1;
}

/*Checks the top side of the maze for an entrance*/
for(j-M-1; j>=0; j--)
{
if(array[0][j] == '0')
entranceM = 0;
entranceN = j;
count = 1;
}
}


}










1 1 1 1 1 1 1 0 1 1
1 1 0 0 1 0 0 0 0 1
1 0 0 0 1 0 0 1 1 1
1 0 0 0 0 0 0 0 0 1
0 0 1 0 0 1 0 1 0 1
1 1 0 0 0 1 0 1 1 1
1 1 0 1 1 0 0 0 0 1
1 0 1 0 0 1 0 0 0 1
1 1 1 0 1 0 1 0 1 1
1 0 0 1 0 1 0 0 0 1
1 0 0 0 1 1 1 0 1 1
1 1 1 1 1 1 1 0 1 1

Explanation / Answer

Also, you need brackets around your if statements. }
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote