program Project1;
{$APPTYPE CONSOLE}
type
PNode = ^TNode;
TNode = record
Value: Integer;
LeftChild, RightChild: PNode
end;
var
Tree: PNode;
a: array [1..10] of Integer;
i: Integer;
procedure Insert(var Root: PNode;
Value: Integer);
begin
if Root=nil then
begin
New(Root);
Root.Value:=Value;
Root.LeftChild:=nil;
Root.RightChild:=nil
end
else
if Value<Root.Value then
Insert(Root.LeftChild, Value)
else
Insert(Root.RightChild, Value)
end;
procedure Print(Root: PNode);
begin
if Root=nil then
Exit;
Print(Root^.LeftChild);
Write(Root^.Value, ' ');
Print(Root^.RightChild)
end;
begin
Randomize;
Tree:=nil;
for i:=1 to 10do
a:=Random(100);
for i:=1 to 10do
Insert(Tree, a);
Print(Tree);
ReadLn
end.