program exp; uses crt; Type PTree = ^TTree; TTree = Record Data : Integer; Left, Right : PTree; end; var Tree : PTree; f1 :text; i, sum, y1 : integer; Procedure InsTree(var ANode : PTree; n : integer); Begin if ANode = nil then Begin new(ANode); With ANode^ do Begin Left := nil; Right := nil; Data := n; end; end else if n< ANode^.Data then InsTree(ANode^.Left, n) else InsTree(ANode^.Right, n); End; Procedure PrintList(ANode : PTree); Begin if ANode <> nil then Begin if (ANode^.Left=nil) and (ANode^.Right=nil) then write(' ', ANode^.Data); PrintList(ANode^.Left); PrintList(ANode^.Right); End; End; begin clrScr; assign(f1,'t1.txt'); reset(f1); while not eof(f1) do begin readln(f1,i); InsTree(Tree, i); end; writeln('Листья дерева'); PrintList(Tree); close(f1); end. for some reason it does not remove the leaves, I have so scored my head that I cannot figure out the simple. Who can help