这个结果为什么不正确呢?
unit Unit1;inte**ce
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
btn1: TButton;
mmo1: TMemo;
procedure btn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function sum(const A:array of Integer): Integer;
var
I:Integer;
begin
for I := Low(A) to High(A) do
Result := Result + A;
end;
procedure TForm1.btn1Click(Sender: TObject);
var
Summer1,Summer2:Integer;
begin
Summer1 := sum();
ShowMessage('数组1:sum=' + IntToStr(Summer1));
Summer2 := sum();
ShowMessage('数组2:sum=' + IntToStr(Summer2));
end;
end.
程序运行后,计算得Summer1 = 15,是正确的
而summer2=262169
这是怎么计算出来的呢?
页:
[1]