TYPE pointer=^tnodetp;
tnodetp=RECORD data: char; llink
linkstack=^linknodet;
linknodet=RECORD data:pointer
PROC unknown (VAR t:pointer);
VAR p
BEGIN p:=t;
IF p<> NIL THEN
[temp:=p^
unknown(p^
END;
① 指出該算法完成了什麼功能
② 用棧將以上算法改為非遞歸算法unknown
PROC inistack(VAR s:linkstack);
(
ENDP;
FUNC empty (s:linkstack):boolean;
IF (
ENDF;
FUNC gettop(s:linkstack):pointer;
gettop:= (
ENDF;
FUNC pop(VAR s:linkstack)
VAR p:linkstack;
pop:=s^
ENDF;
PROC push (VAR s:linkstack;x:pointer);
VAR p:linkstack;
new(p); p^
ENDP;
PROC unknown
VAR p
BEGIN
inistack(s); finish:=false; p:=t;
REPEAT
WHILE p<> NIL DO
[temp:=p^
(
IF (
UNTIL (
ENDP; 【北方交通大學
[
From:http://tw.wingwit.com/Article/program/sjjg/201311/23475.html