annotate lab2/pascal.p @ 0:bfdcc3820b32

Basis
author Mike Spivey <mike@cs.ox.ac.uk>
date Thu, 05 Oct 2017 08:04:15 +0100
parents
children
rev   line source
0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
1 (* lab2/pascal.p *)
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
2
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
3 var a: array 5 of array 5 of integer;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
4 var i, j: integer;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
5
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
6 begin
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
7 i := 0;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
8 while i < 5 do
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
9 a[i][0] := 1; j := 1;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
10 print a[i][0];
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
11 while j <= i do
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
12 a[i][j] := a[i-1][j-1] + a[i-1][j];
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
13 print a[i][j];
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
14 j := j+1
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
15 end;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
16 newline;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
17 i := i+1
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
18 end
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
19 end.
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
20
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
21 (*<<
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
22 1
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
23 1 1
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
24 1 2 1
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
25 1 3 3 1
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
26 1 4 6 4 1
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
27 >>*)