begin var k := Window.Width / Window.Height; Brush.Color := clForestGreen;
for var i := 0 to Window.Height do begin var p := new System.Drawing.Point(round(k * i), i); FillRectangle(p.X, p.Y, p.X + w, p.Y + w); Sleep(delay); Window.Clear(clYellowGreen); end;
for var i := 0 to Window.Height do begin var p := new System.Drawing.Point(Window.Width - round(k * i), i); FillRectangle(p.X - w, p.Y, p.X, p.Y + w); Sleep(delay); Window.Clear(clYellowGreen); end; end.
// PascalABC.NET 3.1, сборка 1219 от 16.04.2016 begin var n:=ReadInteger('Кол-во элементов:'); var a:=ArrRandomReal(n,-10,20); a.Println; Writeln('С округлением если |x|<1'); for var i:=0 to n-1 do if abs(a[i])<1 then a[i]:=Round(a[i]); a.Println end.
uses GraphABC;
const
w = 30;
delay = 12;
begin
var k := Window.Width / Window.Height;
Brush.Color := clForestGreen;
for var i := 0 to Window.Height do
begin
var p := new System.Drawing.Point(round(k * i), i);
FillRectangle(p.X, p.Y, p.X + w, p.Y + w);
Sleep(delay);
Window.Clear(clYellowGreen);
end;
for var i := 0 to Window.Height do
begin
var p := new System.Drawing.Point(Window.Width - round(k * i), i);
FillRectangle(p.X - w, p.Y, p.X, p.Y + w);
Sleep(delay);
Window.Clear(clYellowGreen);
end;
end.
begin
var n:=ReadInteger('Кол-во элементов:');
var a:=ArrRandomReal(n,-10,20); a.Println;
Writeln('С округлением если |x|<1');
for var i:=0 to n-1 do
if abs(a[i])<1 then a[i]:=Round(a[i]);
a.Println
end.
Тестовое решение:
Кол-во элементов: 10
-0.751956142835299 5.95022566427953 3.58861613254464 7.42331713783709 -4.75036238075717 -9.41228387384316 -0.700975591643235 3.85500546258642 -1.94321916994789 19.3021338336645
С округлением если |x|<1
-1 5.95022566427953 3.58861613254464 7.42331713783709 -4.75036238075717 -9.41228387384316 -1 3.85500546258642 -1.94321916994789 19.3021338336645