Data update
This commit is contained in:
parent
81fd053722
commit
52a6ef48dd
10248 changed files with 63654 additions and 6775 deletions
36
Task/Visualize-a-tree/XPL0/visualize-a-tree.xpl0
Normal file
36
Task/Visualize-a-tree/XPL0/visualize-a-tree.xpl0
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
int SDown, SLast, SNone;
|
||||
|
||||
proc Tree(Root, Head);
|
||||
int Root, Head;
|
||||
int Col(2), Tail, R;
|
||||
def \Stem\ Str, Next;
|
||||
[Col(Str):= 0; Col(Next):= 0;
|
||||
Tail:= Head;
|
||||
loop [if Tail = 0 then quit;
|
||||
Text(0, Tail(Str));
|
||||
if Tail(Next) = 0 then quit;
|
||||
Tail:= Tail(Next);
|
||||
];
|
||||
Text(0, "--"); IntOut(0, Root); CrLf(0);
|
||||
|
||||
if Root <= 1 then return;
|
||||
|
||||
if Tail # 0 then
|
||||
if Tail(Str) = SLast then
|
||||
Tail(Str):= SNone;
|
||||
|
||||
if Tail = 0 then [Tail:= Col; Head:= Col]
|
||||
else Tail(Next):= Col;
|
||||
|
||||
while Root do \\ make a tree by doing something random
|
||||
[R:= 1 + Ran(Root);
|
||||
Root:= Root - R;
|
||||
Col(Str):= if Root # 0 then SDown else SLast;
|
||||
Tree(R, Head);
|
||||
];
|
||||
Tail(Next):= 0;
|
||||
];
|
||||
|
||||
[SDown:= " |"; SLast:= " `"; SNone:= " ";
|
||||
Tree(8, 0);
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue