Send the characters which is from base to top to the processing data storage area; ClearsStack(S);∥重置S为空栈 if(ch!= EOF)ch= getchar; Destroy Stack(s)
Send the characters which is from base to top to the processing data storage area; ClearStack(S); // 重置S为空栈 if (ch != EOF) ch = getchar(); } DestroyStack(s); }
Maze solving Common method is exhaust algorithm ########## # ↓#S「SS# #I S S# ####### SS|## ### # # # # ####### ###|#|# →⊙# ##########
Maze solving Common method is exhaust algorithm # # # # # # # # # # # → # $ $ $ # # # # $ $ $ # # # $ $ # # # # # # # # # # → → # # # # # → → # # # # # # # # # # # → → → # # # # # # # # # # #
. The basic idea of maze solving When the current position is feasible then store the path, go ahead When the current position is unfeasible, then go back and change directions If all directions are unfeasible. delete the current position from the path
❖The basic idea of maze solving • When the current position is feasible , then store the path , go ahead; • When the current position is unfeasible, then go back and change directions. • If all directions are unfeasible , delete the current position from the path
set the initial value of current position as entry position; do t if the current position is feasible then( push the current position to stack i if this position is exit position, the algorithm end else set the box east of current position as the new current position else i ●●●6●。。● 3 while(stack is not empty):
set the initial value of current position as entry position; do{ if the current position is feasible, then{push the current position to stack; if this position is exit position, the algorithm end ; else set the box east of current position as the new current position. } else { ……….. } }while (stack is not empty);
If stack is not empty and the top position has other directions not be exploited Then set the new current position: find the next adjacent box of the top position along the clockwise rotation; If stack is not empty and all directions are unfeasible. then i delete the top of stack;∥从路径中删去该通道块 if stack is not empty, then test the new top position until find an adjacent reachable box or stack is empty;
If stack is not empty and the top position has other directions not be exploited. Then set the new current position : find the next adjacent box of the top position along the clockwise rotation; If stack is not empty and all directions are unfeasible. then{ delete the top of stack;// 从路径中删去该通道块 if stack is not empty , then test the new top position, until find an adjacent reachable box or stack is empty; }