求教,这里用了什么算法。
int stackFind2(Index idx1, Index idx2){register int i, j, count = 0;
maze[idx1.y][idx1.x] = 11;
for(;;){
count = 0;
for(i = 1; i < maxIdxY - 1; i++){
for(j = 1; j < maxIdxX - 1; j++){
if(maze[i][j] == 11){
if(maze[i + 1][j] == 0){
maze[i + 1][j] = 11;
count++;
}
if(maze[i][j + 1] == 0){
maze[i][j + 1] = 11;
count++;
}
if(maze[i - 1][j] == 0){
maze[i - 1][j] = 11;
count++;
}
if(maze[i][j - 1] == 0){
maze[i][j - 1] = 11;
count++;
}
}
if(maze[idx2.y][idx2.x] == 11) return 1; /* 关键测试,可大大提高运行效率 */
}
}
if(count == 0)
return ((maze[idx2.y][idx2.x] == 11) ? 1 : 0);
}
}