1 条题解
-
0
Pascal :
program qi26868; type point=^treetype; treetype=record data:char; son1,son2:point; end; var head:point; procedure du(var head:point); var p:point; ch:char; k,top:longint; s:array[1..100]of point; begin read(ch); k:=0; top:=0; while ch<>'#' do begin case ch of 'A'..'Z': begin new(p); p^.data:=ch; p^.son1:=nil; p^.son2:=nil; if top<>0 then begin if k=1 then s[top]^.son1:=p; if k=2 then s[top]^.son2:=p; end; end; '(':begin top:=top+1; s[top]:=p; k:=1; end; ')':top:=top-1; ',':k:=2; end; read(ch); end; head:=s[1]; end; procedure xianxu(head:point); begin if head<>nil then begin write(head^.data); xianxu(head^.son1); xianxu(head^.son2) end; end; begin du(head); xianxu(head); end.
- 1
信息
- ID
- 3548
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- (无)
- 标签
- 递交数
- 0
- 已通过
- 0
- 上传者