同意StreamOne(梦醒)
毕竟array of array 是官方推荐的
Multidimensional dynamic arrays
以下来自Object Pascal Reference
To declare multidimensional dynamic arrays, use iterated array of ... constructions. For example,
type TMessageGrid = array of array of string;
var Msgs: TMessageGrid;
declares a two-dimensional array of strings. To instantiate this array, call SetLength with two integer arguments. For example, if I and J are integer-valued variables,
SetLength(Msgs,I,J);
allocates an I-by-J array, and Msgs[0,0] denotes an element of that array.
You can create multidimensional dynamic arrays that are not rectangular. The first step is to call SetLength, passing it parameters for the first n dimensions of the array. For example,
var Ints: array of array of Integer;
SetLength(Ints,10);
allocates ten rows for Ints but no columns. Later, you can allocate the columns one at a time (giving them different lengths); for example
SetLength(Ints[2], 5);
makes the third column of Ints five integers long. At this point (even if the other columns haven’t been allocated) you can assign values to the third column, for example, Ints[2,4] := 6.
The following example uses dynamic arrays (and the IntToStr function declared in the SysUtils unit) to create a triangular matrix of strings.
type
A1=record
b:integer;
end;
A2=record
a:integer;
MySub: array of A1;
end; //这样你要多少维都可以,这里是二维
var
A:array of A2;
setlength(A,10);//分配
//赋值
for i:=0 to 9 do
begin
A[i].a:=i;
setlength(A[i].MySub,10)
for j:=0 to 9 do
A[i].Mysub[j].b:=j;
end;
//这样释放二维数组:(依次类推)
for i := 0 to 9 do SetLength(A[i], 0);
SetLength(A, 0);