如果我的函数参数中要用到数组(100分)

  • 主题发起人 mybubble
  • 开始时间
M

mybubble

Unregistered / Unconfirmed
GUEST, unregistred user!
以如我要传递array[0..6] of string这样的数组。我在函数参数中如何写呢?
 
type definesz=array[0..6] of string;

function(sz:definesz)
 
function(s:array of string)

用的时候
for i:=low(s) to high(s) do
begin
end;
 
这是动态数组的传递:
procedure PassDnyArray(arr:array of integer);
var
i:integer;
begin
for i:=1 to GetLength(arr) do PrintInteger(arr)

end;

procedure UseDnyArray;
var
dnyA:array of integer;
i:integer;
begin
setlength(dnyA,10)
for i:=1 to 10 do dnyA:=i;
PassDnyArr(dnyA);
end;
 
看下面的用法:
function Max(A: array of integer): integer;
var
x,i : integer;
begin
x := A[0];
for i := 1 to Length(A)-1 do
begin
if x<A then
x := A;
end;
Result := x;
end
 
顶部