unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
const N :Cardinal = 10000000;
var
  i :Cardinal;
  x,y :Double;
  trafienia :Cardinal;
  wynik :Double;
begin
Randomize;
trafienia:=0;
for i:=1 to N do
  begin
  x:=Random;
  y:=Random;
  if Sqr(x)+Sqr(y)<1 then Inc(trafienia);
  end;
wynik:=4*trafienia/N;
ShowMessage('Wynik: '+FloatToStr(wynik)+#13+'Dokładność: '+FloatToStr(Abs(Pi-wynik)));
end;

end.
