diff options
Diffstat (limited to 'challenge-003/abigail/pascal/ch-2.p')
| -rw-r--r-- | challenge-003/abigail/pascal/ch-2.p | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/challenge-003/abigail/pascal/ch-2.p b/challenge-003/abigail/pascal/ch-2.p new file mode 100644 index 0000000000..596acce61d --- /dev/null +++ b/challenge-003/abigail/pascal/ch-2.p @@ -0,0 +1,36 @@ +Program ch2; + +(* *) +(* See https://theweeklychallenge.org/blog/perl-weekly-challenge-003 *) +(* *) + +(* *) +(* Run as: fpc -och-2.out ch-2.p; ./ch-2.out < input-file *) +(* *) + +var + max: integer; + row, col: integer; + current_row, next_row: array of integer; + +begin + while not eof do begin + readln (max); + setlength (current_row, 1); + current_row [0] := 1; + writeln (1); + + for row := 1 to max do begin + setlength (next_row, row + 1); + next_row [0] := 1; + next_row [row] := 1; + write ('1 '); + for col := 1 to row - 1 do begin + next_row [col] := current_row [col - 1] + current_row [col]; + write (next_row [col], ' '); + end; + writeln ('1'); + current_row := next_row; + end + end +end. |
