procedure try(k:integer);
begin
if c=length(z) then begin
showmessage(c);
c是其中一种出栈结果
exit;end;
选择入栈
if k<=length(z) then
begin
s:=s+z[k];
inc(top);
try(k+1);
dec(top);
delete(s,length(s),1);
end;
选择出栈
if top>=1 then
begin
c:=c+s[top];
dec(top);
try(k);
inc(top);
end;
end;