Ответ:
var a:array [1..10] of real;
i:integer;
begin
write('Массив: ');
for i:=1 to 10 do
a[i]:=random(41)-20;
write(a[i]:5)
end;
writeln;
if a[i] > 0 then a[i]:=a[i]/2;
if a[i] < 0 then a[i]:=i;
end
end.
Объяснение:
===== PascalABC.NET =====
var a := ArrRandomReal(10, -99, 99); // случайные числа
a.Transform(p -> Round(p, 2)); // дробная часть - 2 знака
a.Println;
for var i := 0 to a.High do
if a[i] > 0 then
a[i] /= 2
else if a[i] < 0 then
a[i] := i + 1;
a.Println
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
Ответ:
var a:array [1..10] of real;
i:integer;
begin
write('Массив: ');
for i:=1 to 10 do
begin
a[i]:=random(41)-20;
write(a[i]:5)
end;
writeln;
write('Массив: ');
for i:=1 to 10 do
begin
if a[i] > 0 then a[i]:=a[i]/2;
if a[i] < 0 then a[i]:=i;
write(a[i]:5)
end
end.
Объяснение:
===== PascalABC.NET =====
begin
var a := ArrRandomReal(10, -99, 99); // случайные числа
a.Transform(p -> Round(p, 2)); // дробная часть - 2 знака
a.Println;
for var i := 0 to a.High do
if a[i] > 0 then
a[i] /= 2
else if a[i] < 0 then
a[i] := i + 1;
a.Println
end.