
ЗАПОВНІТЬ ПРОПУЩЕНІ ФРАГМЕНТИ: procedure TForm1.Button1Click(Sender: TObject); var: array [] of
real; i,n: integer; max,min: ; begin n: Memo1.Lines.Count; for i:=0 to n-1 do a[i]: StrToFloat( ; max:=_ D); min:__________; for i:=_ if a[i]>_ if a[i]< Edit1. :-FloatToStr(______); Edit2. to n-1 do then then min:=______; else (min);

Ответы на вопрос

Відповідь:
procedure TForm1.Button1Click(Sender: TObject);
var a: array [] of real;
i,n: integer;
max,min: real;
begin
n:= Memo1.Lines.Count;
for i:=0 to n-1 do
a[i]:= StrToFloat(Memo1.Lines[i]);
max:= a[0];
min:= a[0];
for i:= 1 to n-1 do
if a[i]>max then max:= a[i];
else if a[i]<min then min:= a[i];
Edit1.Text:= FloatToStr(max);
Edit2.Text:= FloatToStr(min);
end;
Пояснення:



Based on the provided code, it seems like you're writing a procedure in Delphi (Object Pascal) to perform some operations on an array of real numbers. However, there are some missing parts in the code you provided. I'll help you fill in the blanks:
pascalprocedure TForm1.Button1Click(Sender: TObject); var a: array of real; // Declare array of real i, n: integer; max, min: real; // Declare max and min as real numbers begin n := Memo1.Lines.Count; // Get the number of lines in Memo1 // Initialize the array length SetLength(a, n); // Fill the array with values from Memo1 for i := 0 to n - 1 do a[i] := StrToFloat(Memo1.Lines[i]); max := a[0]; // Initialize max with the first element of the array min := a[0]; // Initialize min with the first element of the array for i := 0 to n - 1 do begin if a[i] > max then max := a[i]; if a[i] < min then min := a[i]; end; Edit1.Text := FloatToStr(max); // Convert max to string and assign to Edit1 Edit2.Text := FloatToStr(min); // Convert min to string and assign to Edit2 end;
Explanation:
SetLength(a, n);
: This line initializes the dynamic arraya
with a length ofn
.a[i] := StrToFloat(Memo1.Lines[i]);
: This line converts the string fromMemo1.Lines[i]
to a real number usingStrToFloat
and assigns it to the corresponding element of the arraya
.max := a[0];
andmin := a[0];
: These lines initializemax
andmin
with the first element of the arraya
.The loop
for i := 0 to n - 1 do
iterates through the elements of the array and updatesmax
andmin
accordingly.Edit1.Text := FloatToStr(max);
andEdit2.Text := FloatToStr(min);
: These lines convertmax
andmin
to strings usingFloatToStr
and assign them toEdit1
andEdit2
respectively.
Please note that this code assumes that Memo1
, Edit1
, and Edit2
are components available in your Delphi form. Make sure to declare and initialize them appropriately in your form.


Похожие вопросы
Топ вопросов за вчера в категории Информатика







Последние заданные вопросы в категории Информатика
-
Математика
-
Литература
-
Алгебра
-
Русский язык
-
Геометрия
-
Английский язык
-
Химия
-
Физика
-
Биология
-
Другие предметы
-
История
-
Обществознание
-
Окружающий мир
-
География
-
Українська мова
-
Информатика
-
Українська література
-
Қазақ тiлi
-
Экономика
-
Музыка
-
Право
-
Беларуская мова
-
Французский язык
-
Немецкий язык
-
МХК
-
ОБЖ
-
Психология
-
Физкультура и спорт
-
Астрономия
-
Кыргыз тили
-
Оʻzbek tili