uses graph; Type Sides=record x1,y1,x2,y2:real; end; var grDriver, grMode, ErrCode: Integer; Stars:array[1..20] of Sides; i,j:integer; R:real; n:integer; x0,y0:real; {***********************************************************************} Procedure Star(n:integer;x0,y0:real;R:real;var Stars:array of Sides); Var R0:real; bufx,bufy:real; begin R0:=R; R:=3*R; for i:= 1 to n do begin Stars[i].x1:= x0+Trunc(R*Sin(i*2*Pi/n)); Stars[i].y1:= y0+Trunc(R*Cos(i*2*Pi/n)); Stars[i].x2:=x0+Trunc(R0*Sin(i*2*Pi/n)); Stars[i].y2:=y0+Trunc(R0*Cos(i*2*Pi/n)); end; bufx:=Stars[1].x2; bufy:=Stars[1].y2; for i:=1 to n do begin if i=n then begin Stars[i].x2:=Stars[i].x2+((bufx-Stars[i].x2)/ 2); Stars[i].y2:=Stars[i].y2+((bufy-Stars[i].y2)/ 2); end else begin Stars[i].x2:=Stars[i].x2+((Stars[i+1].x2-Stars[i].x2)/ 2); Stars[i].y2:=Stars[i].y2+((Stars[i+1].y2-Stars[i].y2)/ 2); end; end; end; {***********************************************************************} Procedure DrawStar(n:integer;Stars:array of Sides); begin for i:=1 to n do begin if i=n then begin line(Trunc(Stars[i].x1),Trunc(Stars[i].y1),Trunc(Stars[i].x2),Trunc(Stars[i].y2)); line(Trunc(Stars[i].x2),Trunc(Stars[i].y2),Trunc(Stars[1].x1),Trunc(Stars[1].y1)); end else begin line(Trunc(Stars[i].x1),Trunc(Stars[i].y1),Trunc(Stars[i].x2),Trunc(Stars[i].y2)); line(Trunc(Stars[i].x2),Trunc(Stars[i].y2),Trunc(Stars[i+1].x1),Trunc(Stars[i+1].y1)); end; end; end; {***********************************************************************} begin grDriver := Detect; InitGraph(grDriver, grMode, ''); ErrCode := GraphResult; if ErrCode <> grOk then begin Writeln('Graphics error:', GraphErrorMsg(ErrCode)); halt(100) end; n:=3; x0:=325; y0:=225; R:=40; Star(n,x0,y0,R,Stars); DrawStar(n,Stars); readln; end.