Uses GraphABC; var tnk:array of Point; begin Window.Title := 'Танк атакует'; var y := 200; Brush.Color := clGreen; LockDrawing; tnk:=new Point[4]; for var x := 70 to 500 do begin Window.Clear(clWhite); Rectangle(x,y,x+100,y+50); Rectangle(x-25,y+50,x+125,y+75); tnk[0].X:=x-45; tnk[0].Y:=y+75; tnk[1].X:=x-30; tnk[1].Y:=y+120; tnk[2].X:=x+100; tnk[2].Y:=y+120; tnk[3].X:=x+145; tnk[3].Y:=y+75; Rectangle(x+100,y+10,x+225,y+25); FillPolygon(tnk); Redraw; Sleep(3); end; end.
// PascalABC.NET 3.1, сборка 1171 от 15.02.2016 begin var i,j:integer; var n:=ReadInteger('n='); var a:=ArrRandom(n,10,99); a.Println; var imax:=0; var imin:=0; for i:=1 to n-1 do if a[i]>a[imax] then imax:=i else if a[i]<a[imin] then imin:=i; if imin<imax then begin for i:=imin+1 to imax-1 do for j:=imin+1 to imax-1 do if a[i]>a[j] then Swap(a[i],a[j]) end else for i:=imax+1 to imin-1 do for j:=imax+1 to imin-1 do if a[i]>a[j] then Swap(a[i],a[j]); a.Println end.
var tnk:array of Point;
begin
Window.Title := 'Танк атакует';
var y := 200;
Brush.Color := clGreen;
LockDrawing;
tnk:=new Point[4];
for var x := 70 to 500 do begin
Window.Clear(clWhite);
Rectangle(x,y,x+100,y+50);
Rectangle(x-25,y+50,x+125,y+75);
tnk[0].X:=x-45;
tnk[0].Y:=y+75;
tnk[1].X:=x-30;
tnk[1].Y:=y+120;
tnk[2].X:=x+100;
tnk[2].Y:=y+120;
tnk[3].X:=x+145;
tnk[3].Y:=y+75;
Rectangle(x+100,y+10,x+225,y+25);
FillPolygon(tnk);
Redraw;
Sleep(3);
end;
end.
begin
var i,j:integer;
var n:=ReadInteger('n=');
var a:=ArrRandom(n,10,99); a.Println;
var imax:=0;
var imin:=0;
for i:=1 to n-1 do
if a[i]>a[imax] then imax:=i
else
if a[i]<a[imin] then imin:=i;
if imin<imax then begin
for i:=imin+1 to imax-1 do
for j:=imin+1 to imax-1 do
if a[i]>a[j] then Swap(a[i],a[j])
end
else
for i:=imax+1 to imin-1 do
for j:=imax+1 to imin-1 do
if a[i]>a[j] then Swap(a[i],a[j]);
a.Println
end.
Тестовое решение:
n= 15
46 87 95 49 86 17 43 61 15 57 23 60 84 75 82
46 87 95 86 61 49 43 17 15 57 23 60 84 75 82