Could anybody give out a test that let this program go wrong?
Could anybody give out a test that let this program go wrong?
Code:
type ac=^acm;
acm=record
v1:longint;
v2:longint;
left,right:ac;
end;
var a,c:ac;
b,d,e,f,g,h,i,j,k,l,m,n,s,p,r:longint;
function mln(a:longint):extended;
begin
if a=0 then exit(a) else exit(ln(a));
end;
procedure goal3(m,l,n:longint);
var i,j,b,p:longint;
procedure goal1(var a:ac);
begin
if a=nil then begin
new(a);
a^.left:=nil;
a^.right:=nil;
a^.v1:=b;
a^.v2:=p;
inc(s);
end
else if b=a^.v1 then
else if b<a^.v1 then
goal1(a^.left)
else
goal1(a^.right);
end;
begin
j:=m div 11;
i:=m-j;
if i div 10=j then begin
b:=i*l+n div 2;
p:=j*l+n div 2;
if trunc(mln(b)/mln(10))+1>trunc(mln(p)/mln(10))+1 then
goal1(a);
end;
if (m div 10>0)and not odd(m mod 10) then goal3(m div 10,l*10,(m mod 10)*l+n);
if (m div 10>1)and not odd(m mod 10) then goal3(m div 10-1,l*10,(m mod 10+10)*l+n);
end;
procedure goal2(a:ac);
var i:longint;
begin
if a^.left<>nil then goal2(a^.left);
if a<>nil then begin
write(a^.v1,' + ');
for i:=trunc(mln(a^.v2)/mln(10))+2 to trunc(mln(a^.v1)/mln(10)) do
write('0');
writeln(a^.v2,' = ',k);
end;
if a^.right<>nil then goal2(a^.right);
end;
begin
read(m);
k:=m;
s:=0;
a:=nil;
goal3(m,1,0);
writeln(s);
goal2(a);
end.