uses crt,graph;
const r=20;h=5;
var gd,gm,i,n,t,x,y,p:integer;
begin
clrscr;
gd:=Detect;
initgraph(gd,gm,'c:\bp\bgi ');
setcolor(4);
setlinestyle(0,1,1);
line(0,479,639,479);
x:=r;y:=r;
t:=479-2*r;
n:=t div h;
p:=h;
while n<>0 do begin
for i:=1 to n do begin
setcolor(2);
circle(x,y,r);
setfillstyle(1,2);
floodfill(x,y,2);
delay(10);
setcolor(0);
circle(x,y,r);
setfillstyle(1,0);
floodfill(x,y,0);
y:=y+p;
x:=x+1;
end;
if p>0 then begin t:=round(3*t/4);n:=t div h end;
p:=-p end;
setcolor(12);
circle(x,y,r);
setfillstyle(1,2);
floodfill(x,y,12);
repeat until keypressed;closegraph
end.