home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
magazine
/
drdobbs
/
1988
/
03
/
porter
/
porter.ls1
next >
Wrap
Text File
|
1987-12-29
|
2KB
|
47 lines
Program maddints;
{ This program illustrates addition of two 180 x 180 integer }
{ matrices A and B, storing the results in a similar matrix C }
Const max = 180; { maximum columns/rows per square array }
Type arrayPtr = ^bigArray;
bigArray = array [1..max, 1..max] of integer;
Var A, B, C : arrayPtr;
x, y : word;
{ ------------------------------------------------------------- }
Procedure acquire (var D : arrayPtr);
{ Allocates the array on the heap and fills it with data }
{ This is a sample procedure for demo only. Replace it with }
{ the requisite code to acquire data from an external source }
Var r, c : word;
Begin
New (D); { allocate a node }
For r := 1 to max do
For c := 1 to max do
D^ [r, c] := (r * 10) + c; { value of each array element }
End;
{ --------------------------- }
Begin { main program }
Acquire (A); { acquire array data }
Acquire (B);
New (C); { set aside space for result }
For y := 1 to max do
For x := 1 to max do
C^ [y, x] := A^ [y, x] + B^ [y, x]; { add arrays into C }
Writeln ('Proof:');
Writeln ('A [1, 1] = ', A^ [1, 1]);
Writeln ('B [1, 1] = ', B^ [1, 1]);
Writeln ('C [1, 1] = ', C^ [1, 1]);
Writeln;
Writeln ('A [max, max] = ', A^ [max, max]);
Writeln ('B [max, max] = ', B^ [max, max]);
Writeln ('C [max, max] = ', C^ [max, max]);
End.