with ada.text_io, ada.integer_text_io;
use ada.text_io, ada.integer_text_io;
procedure keresofa is
type node;
type Pnode is access node;
type node is record
e : integer;
left : Pnode;
right : Pnode;
end record;
T : Pnode := null;
f : file_type;
e : integer;
procedure insert(t : in out Pnode; e : in integer) is
begin
if t = null then
t := new Node'(e,null,null);
else
if e < t.e then
if t.left = null then
t.left := new Node'(e,null,null);
else
insert(t.left,e);
end if;
else
if t.right = null then
t.right := new Node'(e,null,null);
else
insert(t.right,e);
end if;
end if;
end if;
end insert;
procedure inorder(t : in out Pnode) is
begin
if t /= null then
inorder(t.left);
put_line(integer'image(t.e));
inorder(t.right);
end if;
end inorder;
begin
open(f,in_file,"input.txt");
while not end_of_file(f) loop
get(f,e);
insert(T,e);
end loop;
inorder(T);
end keresofa;
VISSZA