Код
unit Laba2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;
type
TForm1 = class(TForm)
end;
pNode = ^tNode;
tNode=record
w:word;
Left,right:pNode;
end;
opt=object(tree)
public
root:pNode;
private
function Createnode:pNode;
function inspath(var t:pNode; L:byte; W:word):boolean;
function decode:byte; //!!!!
end;
var
Form1: TForm1;
implementation
Function opt.inspath(var t:pNode; L:byte; w:word):boolean;
var result:boolean;
begin
if L>0 then
begin
if t^.left=nil then
begin
t^.left:=createnode;
inspath:=inspath(t^.left,L-1,w)
end
else
begin
result:=inspath(t^.left,L-1,w);
if not result then
if t^.right=nil then
begin
t6.right:=createnode;
inspath:=inspath(t^.right,L-1,w)
end
else inspath:=inspath(t^.right,L-1,w)
end
end
else if (t^.left=nil) and (t^.right=nil) and (t^.w=0) then
begin
t^.w:=w;
inspath:=true
end
else inspath:=false
end;
end.
Сообщение отредактировано: RussoTuristo -