//PascalABC.NET 3.1 сборка 1200 function Change(condition: boolean; value, default_value: integer): integer; begin if condition then Change := value else Change := default_value; end;
const n = 12;
begin var a := ArrRandom(n, -10, 10); a.Println;
if a.Where(x -> x > 0).Count > a.Where(x -> x < 0).Count then begin var half_max := a.Max / 2; var mult := 1; mult := a.Where(x -> x > half_max).Aggregate((mult, x)-> mult * x); a.Transform(x -> Change((x < 0), mult, x)); end else a.Transform(x -> Change((x < 0), 0, x));
a.Println; end.
linda3930
09.09.2021
// PascalABC.NET 3.1, сборка 1200 от 13.03.2016 begin var x:=-2.0; while x<=2 do begin Writeln('x=',x:4:1,' y=',x*x*x+12:6:3); x+=0.2 end end.
function Change(condition: boolean; value, default_value: integer): integer;
begin
if condition then
Change := value
else Change := default_value;
end;
const
n = 12;
begin
var a := ArrRandom(n, -10, 10);
a.Println;
if a.Where(x -> x > 0).Count > a.Where(x -> x < 0).Count then begin
var half_max := a.Max / 2;
var mult := 1;
mult := a.Where(x -> x > half_max).Aggregate((mult, x)-> mult * x);
a.Transform(x -> Change((x < 0), mult, x));
end
else
a.Transform(x -> Change((x < 0), 0, x));
a.Println;
end.