procedure TForm1.Button1Click(Sender: TObject); var a:array of array of integer; i,j:integer; begin setlength(a,4); for i:=low(a) to high(a) do SetLength(A[I], 5); a[1,2]:=10; a[3,4]:=10; showmessage(inttostr(a[3,4])); setlength(a,6); for i:=low(a) to high(a) do setlength(a[i],9); a[5,8]:=60; showmessage(inttostr(a[3,4])); showmessage(inttostr(a[5,8]));end;
procedure TForm1.Button2Click(Sender: TObject); var arr :array [0..7,0..4] of char; begin ShowMessageFmt('High(arr)=%d,High(arr[0])=%d',[High(arr)-1,High(arr[0])-1]); end;
m,n值根据你加入下标值的大小来动态改变
var
a:array of array of integer;
i,j:integer;
begin
setlength(a,4);
for i:=low(a) to high(a) do
SetLength(A[I], 5);
a[1,2]:=10;
a[3,4]:=10;
showmessage(inttostr(a[3,4]));
setlength(a,6);
for i:=low(a) to high(a) do
setlength(a[i],9);
a[5,8]:=60;
showmessage(inttostr(a[3,4]));
showmessage(inttostr(a[5,8]));end;
在原来的数组上扩展的(大于原来的数组),原来数组中的值不变。
减小数组,将超出数组Index的值清除,即使再增大,也无法还原原来的值。
var arr :array [0..7,0..4] of char;
begin
ShowMessageFmt('High(arr)=%d,High(arr[0])=%d',[High(arr)-1,High(arr[0])-1]);
end;