Var Num:array of Integer;
在Edit的OnKeyPress中
var i:Integer;
begin
if Key=#13 then
begin
Key:=#0;
SetLength(Num,Length(Num)+1);
Num[Length(Num)-1]:=StrToInt(Edit.Text);
Edit.Text:='';
Memo.Text:='你输入的值:'+#13+#10;
for i:=0 to Length(Num)-1 do
Memo.Text:=Memo.Text+IntToStr(Num[i])+' ';
end;
end;
在求最大值按钮的OnClick中
Var i,j:Integer;
begin
if Length(Num)0 then
begin
if Length(Num) = 1 then
j:=Num[0]
else begin
j:=Num[0];
for i:=1 to Length(Num)-1 do
j:=Max(j,Num[i]);
end;
Memo.Text:='你输入的值:'+#13+#10;
for i:=0 to Length(Num)-1 do
Memo.Text:=Memo.Text+IntToStr(Num[i])+' ';
Memo.Lines.add('最大值为:'+IntToStr(j));
end;
end;
在清除按钮的OnClick中
SetLength(Num,0);
Memo.Text:='';