Skip to content

Commit 71346ac

Browse files
authored
Add Baklava in Modula2 (#4126)
1 parent 662ff1e commit 71346ac

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

archive/m/modula2/Baklava.mod

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
MODULE Baklava;
2+
3+
FROM StrIO IMPORT WriteString, WriteLn;
4+
5+
PROCEDURE WriteRepeatString(s: ARRAY OF CHAR; n: CARDINAL);
6+
VAR i: CARDINAL;
7+
BEGIN
8+
FOR i := 1 TO n DO
9+
WriteString(s);
10+
END
11+
END WriteRepeatString;
12+
13+
VAR
14+
n: INTEGER;
15+
numSpaces: CARDINAL;
16+
numStars: CARDINAL;
17+
18+
BEGIN
19+
FOR n := -10 TO 10 DO
20+
numSpaces := ABS(n);
21+
numStars := 21 - 2 * numSpaces;
22+
WriteRepeatString(' ', numSpaces);
23+
WriteRepeatString('*', numStars);
24+
WriteLn;
25+
END;
26+
END Baklava.

0 commit comments

Comments
 (0)