var
a: array of real;
size, i: integer;
average: real;
begin
randomize;
write('Размер массива: ');
readln(size);
SetLength(a, size);
average := 0;
writeln(' *** Сгенерированный массив *** ');
for i := 0 to size - 1 do
a[i] := random(20);
write(' ', a[i]);
if Odd(i) = false then average := average + a[i];
end;
average := average / trunc((size + 1) / 2);
writeln(#13 + 'Среднее арифметическое = ', average);
writeln(' *** Новый массив ***');
if Odd(i) = true then a[i] := average;
if Frac(a[i]) = 0 then write(' ', a[i])
else write(' ', a[i]:0:1);
end.
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
var
a: array of real;
size, i: integer;
average: real;
begin
randomize;
write('Размер массива: ');
readln(size);
SetLength(a, size);
average := 0;
writeln(' *** Сгенерированный массив *** ');
for i := 0 to size - 1 do
begin
a[i] := random(20);
write(' ', a[i]);
if Odd(i) = false then average := average + a[i];
end;
average := average / trunc((size + 1) / 2);
writeln(#13 + 'Среднее арифметическое = ', average);
writeln(' *** Новый массив ***');
for i := 0 to size - 1 do
begin
if Odd(i) = true then a[i] := average;
if Frac(a[i]) = 0 then write(' ', a[i])
else write(' ', a[i]:0:1);
end;
end.