Jump to content
A-man

2d Arrays

Recommended Posts

From what I've read on the wiki, it seems like T2DpointArray is the way to go, but I don't understand how i'd manipulate an array of like 300x400 or something. Can someone help me out?

 

I've tried:

my_arr[0..300][0..400]: array of integer;

my_arr[0..300, 0..400]: array of integer;

and my_arr: array of integer; followed by setarraylength(my_arr,n);

 

but none of them can do what I'm looking for. Basically I want to be able to store and get values from this table using variables x and y to denote the row and column.

Link to comment
Share on other sites

I had some of those same issues when i first started with these arrays. The best way is to store the data using for loops. remember a 2d array is 2 sets of arrays so ea array needs to have its length set.

 

[scar]

program New;

 

Procedure DoSomething;

Var

ATIA: T2DIntArray;

I,II: Integer;

Begin

// Storing Data dynamicly

For I := 0 to 49 do

Begin

SetLength(ATIA, Length(ATIA) + 1); // increase the first array

For II := 0 to 9 do

Begin

SetLength(ATIA, Length(ATIA) + 1); // increase the Second array

ATIA[iI] := Random(13000);

end;

end;

 

// Storing Data using a fixed array

SetLength(ATIA, 50);

For I := 0 to 49 do

SetLength(ATIA, 10);

 

For I := 0 to 49 do

For II := 0 to 9 do

ATIA[iI] := Random(13000);

 

// Reteriving Data

For I := Low(ATIA) to HIGH(ATIA) do

For II := Low(ATIA) to High(ATIA) do

Writeln(ATIA[iI]);

end;

 

begin

DoSomething;

end.

[/scar]

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
  • Create New...