June 2018 Update
This commit is contained in:
parent
ba8067c3b7
commit
22f33d4004
5278 changed files with 84726 additions and 14379 deletions
37
Task/Floyds-triangle/Modula-2/floyds-triangle.mod2
Normal file
37
Task/Floyds-triangle/Modula-2/floyds-triangle.mod2
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
MODULE FloydTriangle;
|
||||
FROM FormatString IMPORT FormatString;
|
||||
FROM Terminal IMPORT WriteString,WriteLn,ReadChar;
|
||||
|
||||
PROCEDURE WriteInt(n : INTEGER);
|
||||
VAR buf : ARRAY[0..9] OF CHAR;
|
||||
BEGIN
|
||||
FormatString("%4i", buf, n);
|
||||
WriteString(buf)
|
||||
END WriteInt;
|
||||
|
||||
PROCEDURE Print(r : INTEGER);
|
||||
VAR n,i,limit : INTEGER;
|
||||
BEGIN
|
||||
IF r<0 THEN RETURN END;
|
||||
|
||||
n := 1;
|
||||
limit := 1;
|
||||
WHILE r#0 DO
|
||||
FOR i:=1 TO limit DO
|
||||
WriteInt(n);
|
||||
INC(n)
|
||||
END;
|
||||
WriteLn;
|
||||
|
||||
DEC(r);
|
||||
INC(limit)
|
||||
END
|
||||
END Print;
|
||||
|
||||
BEGIN
|
||||
Print(5);
|
||||
WriteLn;
|
||||
Print(14);
|
||||
|
||||
ReadChar
|
||||
END FloydTriangle.
|
||||
Loading…
Add table
Add a link
Reference in a new issue