Zitat von
sk.Silvia:
Delphi-Quellcode:
function TBinTree.FindMin(init:boolean):integer;
begin
//ShowMessage('val '+ValToStr+' res'+inttostr(result));
//result:=result;
if value<result then
begin
result:=value;
end;
if init then result:=self.Value;
if not(left=nil) then result:=left.FindMin(false);
if not(right=nil) then result:=right.FindMin(false);
end;
in prog -> ShowMessage(IntToStr(BinTree.MindMin(true)));
HOW CAN SHOWMESSAGE CHANGE THE RESULT OF A RECURSION????? AND WHY HAVE RESULT:=RESULT; THE SAME EFFECT??
First rule of local variables: Do always initialize them before usage
You forgot that, and that might be the reason for the strange behaviour.
greetz
Mike