unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Math, ExtCtrls, Mask, JvExMask, JvSpin; type TModPoint = record X: Real; Y: Real; end; TForm1 = class(TForm) Button1: TButton; Panel1: TPanel; Label1: TLabel; JvSpinEdit1: TJvSpinEdit; Label2: TLabel; Image1: TImage; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} function PointToModPoint(Point: TPoint): TModPoint; var X, Y: Real; ResPoint: TModPoint; begin X := (Point.X-200)/200; Y := (200-Point.Y)/200; ResPoint.X := X; ResPoint.Y := Y; Result := ResPoint; end; function CheckPoint(ModPoint: TModPoint): Boolean; begin if ((ModPoint.Y >= 0) and (ModPoint.X >= 0)) or ((ModPoint.Y >= 0) and (ModPoint.X <= 0)) then begin if ModPoint.Y <= Sin(ArcCos(ModPoint.X)) then Result := True else Result := False; end else if ((ModPoint.Y <= 0) and (ModPoint.X <= 0)) or ((ModPoint.Y <= 0) and (ModPoint.X >= 0)) then begin if ModPoint.Y >= -Sin(ArcCos(ModPoint.X)) then Result := True else Result := False; end; end; procedure TForm1.Button1Click(Sender: TObject); var Point: TPoint; I, Counter, Max: Integer; begin Randomize; Image1.Canvas.Fillrect(Image1.Canvas.ClipRect); Image1.Canvas.Ellipse(0,0,400,400); Counter := 0; Max := StrToInt(FloatToStr(JvSpinEdit1.Value)); for I := 1 to Max do begin Point.X := Random(400); Point.Y := Random(400); if CheckPoint(PointToModPoint(Point)) = True then begin Counter := Counter+1; Image1.Canvas.Pixels[Point.X, Point.Y] := clRed; end else Image1.Canvas.Pixels[Point.X, Point.Y] := clBlue; Label2.Caption := Format('Tirs: %d || Encerts: %d', [I, Counter]); Label2.Repaint; Image1.Repaint; end; ShowMessage(FloatToStr((Counter/Max)*4)); end; end.