讨论 / 有问题,速请管理员
sxsxsx123890 2011-02-19 05:30:00
点我顶贴 收藏 删除
此题测试数据可有问题

总是出现ORDER#0或1或。。。。(数字),请管理员尽快解决

#1 sxsxsx123890@2011-02-19 05:29:00
回复 删除
此题太。。。。

附代码:program project1;

var s,st:array[1..10001]of char;

s1,s2:string;

n,k,i,j,t,w:longint;

procedure z(i:longint);

begin

if i<=n then

begin

z(i*2);

write(s[i]);

z(i*2+1);

end;

end;

procedure q(i:longint);

begin

if i<=n then

begin

write(s[i]);

q(i*2);

q(i*2+1);

end;

end;

procedure h(i:longint);

begin

if i<=n then

begin

h(i*2);

h(i*2+1);

write(s[i]);

end;

end;

procedure encode(s1:string);

begin

if s1='INORDER' then z(1);

if s1='PREORDER' then q(1);

if s1='POSTORDER' then h(1);

end;

procedure z1(i:longint);

begin

if i<=n then

begin

z1(i*2);

inc(k);

st[i]:=s[k];

z1(i*2+1);

end;

end;

procedure q1(i:longint);

begin

if i<=n then

begin

inc(k);

st[i]:=s[k];

q1(i*2);

q1(i*2+1);

end;

end;

procedure h1(i:longint);

begin

if i<=n then

begin

h1(i*2);

h1(i*2+1);

inc(k);

st[i]:=s[k];

end;

end;

procedure decode(s1:string);

begin

k:=0;

if s1='INORDER' then z1(1);

if s1='PREORDER' then q1(1);

if s1='POSTORDER' then h1(1);

end;

begin

readln(t);

for i:=1 to t do

begin

readln(s1);

s2:=copy(s1,1,pos(' ',s1)-1);

val(s2,n);

delete(s1,1,pos(' ',s1));

s2:=copy(s1,pos(' ',s1)+1,length(s1)-pos(' ',s1));

s1:=copy(s1,1,pos(' ',s1)-1);

for j:=1 to n do

read(s[j]);

readln;

write('Order #',t-i+1);

writeln;

if s2='ENCODE' then begin encode(s1); writeln; end;

if s2='DECODE' then begin decode(s1); for w:=1 to k do write(st[w]); writeln; end;

end;

end.

write('Order #',t-i+1);

这个害我交了好几次

#2 sxsxsx123890@2011-02-19 05:30:00
回复 删除
100题纪念啊

终于一百题了,辛苦啊......-_-...

查看更多回复
提交回复