Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
33
Task/Pascals-triangle/Modula-2/pascals-triangle.mod2
Normal file
33
Task/Pascals-triangle/Modula-2/pascals-triangle.mod2
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
MODULE Pascal;
|
||||
FROM FormatString IMPORT FormatString;
|
||||
FROM Terminal IMPORT WriteString,WriteLn,ReadChar;
|
||||
|
||||
PROCEDURE PrintLine(n : INTEGER);
|
||||
VAR
|
||||
buf : ARRAY[0..63] OF CHAR;
|
||||
m,j : INTEGER;
|
||||
BEGIN
|
||||
IF n<1 THEN RETURN END;
|
||||
m := 1;
|
||||
WriteString("1 ");
|
||||
FOR j:=1 TO n-1 DO
|
||||
m := m * (n - j) DIV j;
|
||||
FormatString("%i ", buf, m);
|
||||
WriteString(buf)
|
||||
END;
|
||||
WriteLn
|
||||
END PrintLine;
|
||||
|
||||
PROCEDURE Print(n : INTEGER);
|
||||
VAR i : INTEGER;
|
||||
BEGIN
|
||||
FOR i:=1 TO n DO
|
||||
PrintLine(i)
|
||||
END
|
||||
END Print;
|
||||
|
||||
BEGIN
|
||||
Print(10);
|
||||
|
||||
ReadChar
|
||||
END Pascal.
|
||||
Loading…
Add table
Add a link
Reference in a new issue