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 Lab4Tree is
- type Node is
- record
- Data : Integer := 0;
- Left : access Node := Null;
- Right : access Node := Null;
- end record;
- type Node_Ptr is access all Node;
- procedure PrintNode(Tree : access Node_Ptr; Indent : String) is
- begin
- Put(Indent);
- Put(Tree.Data, 4);
- New_Line;
- if Tree.Left /= Null then
- PrintNode(Tree.Left, Indent & " ");
- end if;
- if Tree.Right /= Null then
- PrintNode(Tree.Right, Indent & " ");
- end if;
- end PrintNode;
- procedure Print(Tree : access Node_Ptr) is
- Tmp : access Node_Ptr := Tree;
- begin
- if Tree = Null then
- Put_Line("Empty tree");
- else
- PrintNode(Tmp, "");
- end if;
- end Print;
- TreeInstance : Node_Ptr := Null;
- begin
- Print(TreeInstance);
- end Lab4Tree;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement