讨论 / 为什么全都是普通保护错误
DukeFeng 2012-07-31 21:48:00
点我顶贴 收藏 删除
program asdf;

type tree=^point;

point=record

lch,rch:tree;

data:char;

end;

var i,j,k,l,m,n:longint;

str,wr:ansistring;

t:tree;

function panduan(st:ansistring):char;

var l,i,ling,yi:longint;

begin

l:=length(st);

yi:=0;ling:=0;

for i:=1 to l do

begin

if st[i]='1' then inc(yi);

if st[i]='0' then inc(ling);

if (yi>0)and(ling>0)then exit('F');

end;

if yi=0 then exit('B');

if ling=0 then exit('I');

end;

procedure fang(stt:ansistring;var tr:tree);

var i,j,k:longint;

st1,st2:ansistring;

ch:char;

begin

st1:='';

st2:='';

new(tr);

k:=length(stt);

if k>1 then

begin

tr^.data:=panduan(stt);

for i:=1 to k div 2 do

st1:=st1+stt[i];

for i:=k div 2 +1 to k do

st2:=st2+stt[i];

fang(st1,tr^.lch);

fang(st2,tr^.rch);

end;

if k=1 then

begin

if stt[1]='0' then tr^.data:='B'

else tr^.data:='I';

end;

end;

procedure hou(tr:tree);

begin

if tr<>nil then

begin

hou(tr^.lch);

hou(tr^.rch);

wr:=wr+tr^.data;

end;

end;

begin

read(n);

readln;

read(str);

fang(str,t);

wr:='';

hou(t);

write(wr);

end.

在我机子上运行没有问题啊

查看更多回复
提交回复