Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- with Ada.Text_IO, Ada.Integer_Text_IO;
- use Ada.Text_IO, Ada.Integer_Text_IO;
- procedure ProgB is
- type Element is
- record
- Data : Integer := 0;
- Left : access Element := Null;
- Right : access Element := Null;
- end record;
- type Element_Ptr is access all Element;
- procedure PrintTree(Tree : access Element) is
- begin
- if Tree /= Null then
- Put_Line(Element.Data'Img);
- PrintTree(Element.Left);
- PrintTree(Element.Right);
- end if;
- end PrintTree;
- procedure WstawBst(Tree : in out Element_Ptr, Val : in Integer) is
- E : Element_Ptr := new Element'(Val,Null,Null);
- begin
- if Tree = Null then
- Tree := E;
- elsif Tree.Data == Val then null;
- elsif Tree.Data > Val then
- if Tree.Left \= Null then
- WstawBst(Tree.Left,Val);
- elsif Tree.Left := E;
- end if;
- else
- if Tree.Right \= Null then
- WstawBst(Tree.Right,Val);
- elsif Tree.Right := E;
- end if;
- end if;
- end WstawBst;
- begin
- end ProgB;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement