kolibrios-fun/programs/develop/oberon07/Samples/Windows/Console/SierpinskiTriangle.ob07

44 lines
815 B
Plaintext
Raw Normal View History

(*
adapted to Oberon-07 by 0CodErr, KolibriOS team
*)
MODULE SierpinskiTriangle;
IMPORT In, Out, Console;
VAR
order: INTEGER;
PROCEDURE PrintSierpinski(order: INTEGER);
VAR
x, y, k, size: INTEGER;
BEGIN
size := LSL(1, order) - 1;
FOR y := size TO 0 BY -1 DO
FOR k := 1 TO y DO
Out.Char(" ")
END;
FOR x := 0 TO size - y DO
IF BITS(x) * BITS(y) = {} THEN
Out.String("* ")
ELSE
Out.String(" ")
END
END;
Out.Ln
END
END PrintSierpinski;
BEGIN
Console.open;
Out.String("Input triangle order(0..5):");
In.Int(order);
PrintSierpinski(order);
In.Ln;
Console.exit(TRUE)
END SierpinskiTriangle.