program N_tougao; uses crt,graph; const b=10; var driver,mode,n,i:integer; x,y,xc,yc,r:real; begin ClrScr; write(' Unesite broj temena (n):'); readln(n); write(' Unesite poluprecnik opisane kruznice (r) :'); readln(r); r:=r*b; driver:=detect; InitGraph(driver,mode,''); if (r>0) and (r<((GetMaxX+1) div 2)) and (n>2) then begin xc:=GetMaxX div 2; yc:=GetMaxY div 2; setbkcolor(white); setcolor(magenta); MoveTo(round(xc+r),round(yc)); for i:=1 to n do begin x:=xc+r*cos(2*pi/n*i); y:=yc+r*sin(2*pi/n*i); LineTo(round(x),round(y)); end; SetFillStyle(1,magenta); FloodFill(GetMaxX div 2,GetMaxY div 2,magenta); readln; closegraph end else begin restorecrtmode; writeln(' Objekat nije vidljiv! Poluprecnik mora biti u intervalu [0,',GetMaxY div 2,'], a broj tjemena veci od 2!'); readln end end. |
|