USES crt,graph;
var p:pointer;
    rdm:byte;
procedure init;
var gd,gm:integer;
begin
  gd:=detect;gm:=0;
  initgraph(gd,gm,'c:\limbaje\tp\bgi');
  if graphresult<>grOk then halt(1);
end;
procedure def_bila;                   { deseneaza si salveaza in mem. bila }
begin
{     setcolor(3);setfillstyle(1,3); bar(0,0,12,12); }
     setcolor(red);setfillstyle(1,red); pieslice(6,6,0,360,5);
     setcolor(darkgray); outtextxy(4,3,'-');
     getmem(p,imagesize(0,0,12,12));
     getimage(0,0,12,12,p^);
     cleardevice;
end;

procedure desen;                                { deseneaza semnele + si - }
var l:byte;
    sus,jos:word;
begin
  setbkcolor(3); setcolor(14);
  line(0,20,getmaxx,20);
  line(0,getmaxy-20,getmaxx,getmaxy-20);
  randomize; rdm:=random(2)+1;
  if rdm=1 then begin sus:=6; jos:=getmaxy-14; end
           else begin jos:=6; sus:=getmaxy-14; end;
  for l:=1 to (getmaxx div 2)-1 do
    begin
      setcolor(8);
      outtextxy(10*l,sus,'+');
      outtextxy(10*l,jos,'-');
    end;
end;

procedure misc;   { realiz. misc. bilei spre sarcinile de semn contrar lui }
var i,j,m,max:word;
begin
  m:=0; max:=210;
  for j:=10 to max do
   for i:=1 to 2 do
   begin
     if keypressed then exit;
     if rdm=1 then
       begin
         m:=m+i;
         putimage(6+m,(getmaxy div 2)-6-j,p^,xorput);
         delay(10);
         putimage(6+m,(getmaxy div 2)-6-j,p^,xorput);
       end
     else
       begin
         m:=m+i;
         putimage(6+m,(getmaxy div 2)-6+j,p^,xorput);
         delay(10);
         putimage(6+m,(getmaxy div 2)-6+j,p^,xorput);
       end;
   end;
   if rdm=1 then putimage(6+m,(getmaxy div 2)-6-j,p^,xorput)
            else putimage(6+m,(getmaxy div 2)-6+j,p^,xorput);
end;

begin
init;
def_bila;
desen;
misc;
readln;
end.