Код:
procedure TForm1.Button1Click(Sender: TObject);
var a:array[1..5] of real; i: integer;
max, min, s: real; counter: integer;
begin
if OpenDialog1.Execute then
Begin
AssignFile(f,OpenDialog1.FileName);
Reset(f);
i:=0;
while not eof(f) do
Begin
i:=i+1;
Readln(f,a[i]);
Memo1.Lines.Add(floattostr(a[i]));
end;
end
else
exit;
max:= a[1];
min:= a[1];
s:=a[1];
for i:=1 to length(a) do
if a[i+1]> max then
max:= a[i+1];
If a[i+1]< min then
min:= a[i+1];
Edit1.Text:= floattostr(min+max);
if i mod 2 <>0 then
if abs(a[i+1]) >s then
s:= a[i+1];
Edit2.text:=floattostr(s);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
if SaveDialog1.Execute then Memo1.Lines.SaveToFile(SaveDialog1.FileName);
end;
end.
как сделать чтобы кол-во элементов массива было не фиксированным (в моем случае 5), а менялось автоматически в зависимости от кол-ва чисел в текстовом файле?