Bingo, Computer Graphics & Game Developer
P74页中倒数第二行的else if
if(next_row == EXIT_ROW && next_col == EXIT_COL)
found = TRUE;
else if(!maze[next_row][next_col] && !mark[nextRow][next_col]){
// do something...
}
此处的else if我认为可以更正为if,那么最后一个结点也可以入栈,或者为了性能起见,将stack.push()的在第一步if中添加上也可。个人更倾向于第二种做法。
即(t3DataStructures.t3Maze中就是这样做的)
if(next_row == EXIT_ROW && next_col == EXIT_COL){
stack.push(row, col, dir);
found = TRUE;
}
else if(!maze[next_row][next_col] && !mark[next_row][next_col]){
// do something...
}