Large Array
Author Message
Large Array

Quote:

> I want to create an Array with the size of 800*600 (coordinates). It
> is supposed to be a two dimensional mountain. Each pixel must get an
> X and Y value.

If I understand correctly you want an array of 800x600 where each entry
has two values: X and Y. If I misunderstood then modify XYRecord and use
something else instead of GetX, GetY and SetXY.

So:

program BigArrayDefinitions;
Const
M=600;
N=800;

type
XYRecord = record  { this is an array element }
X,Y : real;
end;

pVector=^tVector;                   { a pointer to a single vector }
tVector = array [1..M] of XYRecord; { the vector }
var
BigArray : array [1..N] of pVector; { a vector of pointers to vectors }

procedure Init;
var i:integer;
begin
for i:=1 to N do new(BigArray[i]); { the actual creation of the vectors }
end;

procedure SetXY(i,j:integer;aX,aY:real);
begin
BigArray[i]^[j].X:=aX;
BigArray[i]^[j].Y:=aY;
end;

function GetX(i,j:integer):real;
begin
GetX:=BigArray[i]^[j].X;
end;

function GetY(i,j:integer):real;
begin
GetY:=BigArray[i]^[j].Y;
end;

begin
init;

{ Put your code here. The following is just an example. }
SetXY(100,500,3.7,19.3);
writeln(GetX(100,500));

end.

Sat, 05 Dec 1998 03:00:00 GMT

 Page 1 of 1 [ 1 post ]

Relevant Pages