ΠΠΈΡΡΠΈΠ½Π³ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΡ.
ΠΠ΅ΡΠΎΠ΄Ρ ΠΠΎΠ½ΡΠ΅-ΠΠ°ΡΠ»ΠΎ ΠΈ ΠΈΡ
ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°Π½ΠΈΠ΅ Π² ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠΈΡΠΎΠ²Π°Π½ΠΈΠΈ
ΠΠ°ΡΠ°Π»ΡΠ½ΡΠ΅ ΠΊΠΎΠΎΡΠ΄ΠΈΠ½Π°ΡΡ ΡΠΎΡΠΊΠΈ. Procedure TForm3. PaintBox1Paint (Sender: TObject); Panel1. Caption:='ΠΠ»ΠΎΡΠ°Π΄Ρ ΡΠΈΠ³ΡΡΡ = '+S; Memo1.Lines.Add (FloatToStrF (r/100,ffFixed, 6,2)); Dialogs, StdCtrls, ExtCtrls, Math, Buttons, Menus; Dialogs, Math, StdCtrls, ExtCtrls, Buttons, Menus; Dialogs, ExtCtrls, StdCtrls, Buttons, jpeg, Menus; Procedure TForm6. BitBtn3Click (Sender: TObject); Procedure TForm6… Π§ΠΈΡΠ°ΡΡ Π΅ΡΡ >
ΠΠΈΡΡΠΈΠ½Π³ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΡ. ΠΠ΅ΡΠΎΠ΄Ρ ΠΠΎΠ½ΡΠ΅-ΠΠ°ΡΠ»ΠΎ ΠΈ ΠΈΡ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°Π½ΠΈΠ΅ Π² ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠΈΡΠΎΠ²Π°Π½ΠΈΠΈ (ΡΠ΅ΡΠ΅ΡΠ°Ρ, ΠΊΡΡΡΠΎΠ²Π°Ρ, Π΄ΠΈΠΏΠ»ΠΎΠΌ, ΠΊΠΎΠ½ΡΡΠΎΠ»ΡΠ½Π°Ρ)
unit Unit2;
interface.
uses.
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,.
Dialogs, ExtCtrls, StdCtrls, Buttons, jpeg, Menus;
type.
TForm2 = class (TForm).
Label1: TLabel;
BitBtn1: TBitBtn;
Image1: TImage;
Label2: TLabel;
Edit1: TEdit;
Panel1: TPanel;
Panel2: TPanel;
BitBtn2: TBitBtn;
Label3: TLabel;
BitBtn3: TBitBtn;
BitBtn4: TBitBtn;
MainMenu1: TMainMenu;
N1: TMenuItem;
N2: TMenuItem;
N3: TMenuItem;
N4: TMenuItem;
N21: TMenuItem;
N5: TMenuItem;
N6: TMenuItem;
N7: TMenuItem;
procedure BitBtn1Click (Sender: TObject);
procedure BitBtn2Click (Sender: TObject);
procedure BitBtn3Click (Sender: TObject);
procedure BitBtn4Click (Sender: TObject);
procedure N3Click (Sender: TObject);
procedure N4Click (Sender: TObject);
procedure N21Click (Sender: TObject);
procedure N6Click (Sender: TObject);
procedure N5Click (Sender: TObject);
procedure N7Click (Sender: TObject);
procedure N2Click (Sender: TObject);
private.
{ Private declarations }.
public.
{ Public declarations }.
end;
const A = -Pi/2.0; B = pi/2.0; n = 1000;
var.
Form2: TForm2;
N_total:longint;
implementation.
uses Unit1, Unit3, Unit4, Unit5, Unit6, Unit8;
{$R *.dfm}.
Function FUNC (x:real):real;
begin.
Func:=Cos (x);
end;
Procedure Graphic (var right, down: integer;
var X_min, X_max, Y_min, Y_max, Kx, Ky: real);
type arr=array[1.n] of real;
var.
X, Y: arr; dx: real;
i: integer;
begin.
dx:=(B-A)/(n-1);
for i:=1 to n do begin X[i]: =A+dx*(i-1);
Y[i]: =FUNC (X[i]);
end;
{ΠΠ°Ρ ΠΎΠΆΠ΄Π΅Π½ΠΈΠ΅ ΠΌΠ°ΠΊΡΠΈΠΌΠ°Π»ΡΠ½ΠΎΠ³ΠΎ ΠΈ ΠΌΠΈΠ½ΠΈΠΌΠ°Π»ΡΠ½ΠΎΠ³ΠΎ Π·Π½Π°ΡΠ΅Π½ΠΈΠΉ ΡΡΠ½ΠΊΡΠΈΠΈ ΠΈ Π°ΡΠ³ΡΠΌΠ΅Π½ΡΠ°}.
X_max:=B; X_min:=A;
Y_max:=Y[1]; Y_min:=Y[1];
for i:=2 to n do begin.
if Y_max < Y[i] then Y_max:=Y[i];
if Y_min > Y[i] then Y_min:=Y[i];
end;
{ΠΠ°Ρ ΠΎΠΆΠ΄Π΅Π½ΠΈΠ΅ ΠΊΠΎΡΡΡΠΈΡΠΈΠ΅Π½ΡΠΎΠ² ΡΠΆΠ°ΡΠΈΡ}.
Kx:=right/(X_max-X_min);
Ky:=down/(Y_max-Y_min);
{Π£ΡΡΡΠ°Π½Π΅Π½ΠΈΠ΅ ΠΈΡΠΊΠ°ΠΆΠ΅Π½ΠΈΡ Π³ΡΠ°ΡΠΈΠΊΠ°}.
if Kx < Ky then begin.
Ky:=Kx;
down:=round ((Y_max-Y_min)*Ky);
end.
else begin.
Kx:=Ky;
right:=round ((X_max-X_min)*Kx);
end;
end;
procedure TForm2. BitBtn1Click (Sender: TObject);
var N_total, N_fig, i: longint;
S_total, S_fig, X, Y:real;
Xg, Yg: integer;
X_min, X_max, Y_min, Y_max, Kx, Ky: real;
Right, Down: integer;
S:string;
begin.
randomize;
With Image1, Canvas do.
begin.
FillRect (ClientRect);
Right := Width;
Down := Height;
Graphic (Right, Down, X_min, X_max, Y_min, Y_max, Kx, Ky);
Width := Right ;
Height := Down ;
{Π ΠΈΡΠΎΠ²Π°Π½ΠΈΠ΅ ΠΎΡΠ΅ΠΉ}.
Xg:=round (-X_min*Kx);
Yg:=Down-round (-Y_min*Ky);
{ΠΡΡ Y}.
MoveTo (Xg, Down);
LineTo (Xg, 0);
moveto (Xg, 0);
lineto (Xg+4, 10);
moveto (Xg, 0);
lineto (Xg-4, 10);
{ΠΡΡ Π₯}.
MoveTo (0, Yg-1);
lineTo (Right, Yg-1);
moveto (Right, Yg);
lineto (Right-10, Yg+5);
moveto (Right, Yg);
lineto (Right-10, Yg-5);
N_fig:=0;
N_total:=StrToInt (Edit1.Text);
{Π ΠΎΠ·ΡΠ³ΡΡΡ ΠΊΠΎΠΎΡΠ΄ΠΈΠ½Π°Ρ ΡΠΎΡΠ΅ΠΊ}.
for i:=1 to N_total do.
begin.
X:=random*(B-A)+A;
Y:=random*(Y_max-Y_min)+Y_min;
if Y <= FUNC (X)then.
begin.
Xg:=round ((X-X_min)*Kx);
Yg:=Down-round ((Y-Y_min)*Ky);
Pixels[Xg, Yg]: =clBlack;
Application.ProcessMessages;
N_fig:=N_fig+1;
end;
end;
end;
S_fig:=(Y_max-Y_min)*(B-A)*N_fig/N_total;
Str (S_fig:10:4,S);
Panel1.Caption:='ΠΠ»ΠΎΡΠ°Π΄Ρ ΡΠΈΠ³ΡΡΡ = '+S;
Panel2.Caption:='Pi = 3.1416';
end;
procedure TForm2. BitBtn2Click (Sender: TObject);
begin.
Form1.Show;
Form2.Hide;
end;
procedure TForm2. BitBtn3Click (Sender: TObject);
begin.
Form1.close;
Form2.Close;
Form3.Close;
Form4.Close;
Form5.Close;
Form6.Close;
end;
procedure TForm2. BitBtn4Click (Sender: TObject);
begin.
Image1.picture:=nil;
Panel1.Caption:='';
end;
procedure TForm2. N3Click (Sender: TObject);
begin.
Form1.close;
Form2.Close;
Form3.Close;
Form4.Close;
Form5.Close;
Form6.Close;
end;
procedure TForm2. N4Click (Sender: TObject);
begin.
Form1.Show;
Form2.Hide;
end;
procedure TForm2. N21Click (Sender: TObject);
begin.
Form3.Show;
end;
procedure TForm2. N6Click (Sender: TObject);
begin.
Form5.Show;
end;
procedure TForm2. N5Click (Sender: TObject);
begin.
Form4.Show;
end;
procedure TForm2. N7Click (Sender: TObject);
begin.
Form6.Show;
end;
procedure TForm2. N2Click (Sender: TObject);
begin.
Form8.Show;
end;
end.
unit Unit3;
interface.
uses.
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,.
Dialogs, StdCtrls, ExtCtrls, Math, Buttons, Menus;
type.
TForm3 = class (TForm).
PaintBox1: TPaintBox;
Label1: TLabel;
Edit1: TEdit;
Label2: TLabel;
Edit2: TEdit;
Label3: TLabel;
Edit3: TEdit;
Memo1: TMemo;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
BitBtn3: TBitBtn;
MainMenu1: TMainMenu;
N1: TMenuItem;
N2: TMenuItem;
N3: TMenuItem;
N4: TMenuItem;
N11: TMenuItem;
Label4: TLabel;
N5: TMenuItem;
N6: TMenuItem;
N7: TMenuItem;
procedure PaintBox1Paint (Sender: TObject);
procedure BitBtn1Click (Sender: TObject);
procedure BitBtn2Click (Sender: TObject);
procedure BitBtn3Click (Sender: TObject);
procedure N11Click (Sender: TObject);
procedure N3Click (Sender: TObject);
procedure N5Click (Sender: TObject);
procedure N6Click (Sender: TObject);
procedure N7Click (Sender: TObject);
procedure N4Click (Sender: TObject);
procedure N2Click (Sender: TObject);
private.
{ Private declarations }.
public.
{ Public declarations }.
end;
var.
Form3: TForm3;
KH: Integer; //ΠΠΎΠ»ΠΈΡΠ΅ΡΡΠ²ΠΎ ΡΠ°Π³ΠΎΠ² ΡΠ΅ΡΠΊΠΈ.
sH: Integer = 0; //Π¨Π°Π³ ΡΠ΅ΡΠΊΠΈ Π² ΠΏΠΈΠΊΡΠ΅Π»Π°Ρ .
Tochka: TPoint; //ΠΠ°ΡΠ° ΡΠΎΡΠΊΠ°.
ArrPoinr: Array Of TPoint;
implementation.
uses Unit1, Unit2, Unit4, Unit5, Unit6, Unit9;
{$R *.dfm}.
procedure TForm3. PaintBox1Paint (Sender: TObject);
Var.
i: Integer;
begin.
If sH=0 Then Exit;
//ΠΠ΅ΡΠ΅ΡΠΈΡΠΎΠ²ΠΊΠ° ΠΏΡΡΠΈ ΡΠΎΡΠΊΠΈ…
With PaintBox1, PaintBox1. Canvas Do.
Begin.
Pen.Color:=clBlack;
//ΠΡΠΈΡΠ°Π΅ΠΌ ΠΏΠΎΠ»Π΅…
FillRect (ClientRect);
//Π ΠΈΡΡΠ΅ΠΌ ΡΠ΅ΡΠΊΡ…
Pen.Width:=1;
for i:=0 to KH do.
begin.
moveto (Min (i*sH, Width-1), 0);
lineto (Min (i*sH, Width-1), Height);
moveto (0,Min (i*sH, Height-1));
lineto (Width, Min (i*sH, Height-1));
end;
Pen.Width:=2; //ΠΠ΅Π»ΠΈΡΠΈΠ½Π° Π»ΠΈΠ½ΠΈΠΈ ΠΌΠ΅ΠΆΠ΄Ρ ΡΠΎΡΠΊΠ°ΠΌΠΈ.
Pen.Color:=clRed;
moveto (ArrPoinr[0]. X*sH, ArrPoinr[0].Y*sH);
Ellipse (ArrPoinr[0]. X*sH-2,ArrPoinr[0].Y*sH-2,ArrPoinr[0].X*sH+2,ArrPoinr[0].Y*sH+2);
For i:=1 To Length (ArrPoinr)-1 Do.
Begin.
//ΠΠΈΠ½ΠΈΡ Π΄ΠΎ ΡΠ»Π΅Π΄ΡΡΡΠ΅ΠΉ ΡΠΎΡΠΊΠΈ.
Lineto (ArrPoinr[i]. X*sH, ArrPoinr[i].Y*sH);
Ellipse (ArrPoinr[i]. X*sH-2,ArrPoinr[i].Y*sH-2,ArrPoinr[i].X*sH+2,ArrPoinr[i].Y*sH+2);
End;
End;
end;
procedure TForm3. BitBtn1Click (Sender: TObject);
Var.
r: Byte;
begin.
Randomize;
Memo1.Lines.Clear;
KH:=StrToInt (Edit1.Text);
//ΠΠ°ΡΠ°Π»ΡΠ½ΡΠ΅ ΠΊΠΎΠΎΡΠ΄ΠΈΠ½Π°ΡΡ ΡΠΎΡΠΊΠΈ.
Tochka.X:=StrToInt (Edit2.Text);
Tochka.Y:=StrToInt (Edit3.Text);
sH:=(PaintBox1.Height Div KH);
SetLength (ArrPoinr, 1); //ΠΠ»Ρ ΠΏΠ΅ΡΠ²ΠΎΠΉ ΡΠΎΡΠΊΠΈ.
ArrPoinr[0]: =Tochka; //ΠΠ΅ΡΠ²ΠΎΠ΅ ΠΏΠΎΠ»ΠΎΠΆΠ΅Π½ΠΈΠ΅ ΡΠΎΡΠΊΠΈ Π² ΠΌΠ°ΡΡΠΈΠ².
//ΠΠ΅ΡΠ΅ΠΌΠ΅ΡΠ°Π΅ΠΌ ΡΠΎΡΠΊΡ…
Repeat.
r:=Random (101);
Case r Of.
0.25: Tochka. X:=Tochka.X+1;
26.50: Tochka. Y:=Tochka.Y-1;
51.75: Tochka. X:=Tochka.X-1;
76.100: Tochka. Y:=Tochka.Y+1; //ΠΠ½ΠΈΠ·.
End;
SetLength (ArrPoinr, Length (ArrPoinr)+1); //ΠΠ»Ρ ΡΠ»Π΅Π΄ΡΡΡΠ΅ΠΉ ΡΠΎΡΠΊΠΈ.
ArrPoinr[Length (ArrPoinr)-1]: =Tochka; //ΠΡΠ΅ΡΠ΅Π΄Π½ΠΎΠ΅ ΠΏΠΎΠ»ΠΎΠΆΠ΅Π½ΠΈΠ΅ ΡΠΎΡΠΊΠΈ Π² ΠΌΠ°ΡΡΠΈΠ².
Memo1.Lines.Add (FloatToStrF (r/100,ffFixed, 6,2));
PaintBox1.OnPaint (Sender);
//.Refresh; //ΠΠ΅ΡΠ΅ΡΠΈΡΡΠ΅ΠΌ PaintBox.
Application.ProcessMessages; //ΠΠΎΠ·Π²ΠΎΠ»ΡΠ΅ΠΌ ΠΏΠ΅ΡΠ΅ΡΠΈΡΠΎΠ²Π°ΡΡ.
Until ((Tochka.X=0) Or (Tochka.Y=0) Or (Tochka.X=10) Or (Tochka.Y=10));
//ΠΠ΅ΡΠ΅ΠΌΠ΅ΡΠ΅Π½ΠΈΠ΅ Π·Π°ΠΊΠΎΠ½ΡΠ΅Π½ΠΎ.
//SetLength (ArrPoinr) = ΠΊΠΎΠ»ΠΈΡΠ΅ΡΡΠ²ΠΎ ΡΠ°Π³ΠΎΠ² ΠΏΠ΅ΡΠ΅ΠΌΠ΅ΡΠ΅Π½ΠΈΡ ΡΠΎΡΠΊΠΈ Π² ΠΌΠ°ΡΡΠΈΠ²Π΅.
//Π² Memo1 — ΡΠΎΠΆΠ΅ Π²ΡΠ΅ Π·Π½Π°ΡΠ΅Π½ΠΈΡ ΠΏΠ΅ΡΠ΅ΠΌΠ΅ΡΠ΅Π½ΠΈΡ ΡΠΎΡΠΊΠΈ.
//ΠΠΠΠ‘Π¬ ΠΠΠ ΠΠΠΠ’ΠΠ…
sH:=0;
Finalize (ArrPoinr); //ΠΡΠ²ΠΎΠ±ΠΎΠΆΠ΄Π°Π΅ΠΌ ΠΏΠ°ΠΌΡΡΡ ΠΌΠ°ΡΡΠΈΠ²Π°…
end;
procedure TForm3. BitBtn2Click (Sender: TObject);
begin.
Form1.close;
Form2.Close;
Form3.Close;
Form4.Close;
Form5.Close;
Form6.Close;
end;
procedure TForm3. BitBtn3Click (Sender: TObject);
begin.
Form1.Show;
Form3.Hide;
end;
procedure TForm3. N11Click (Sender: TObject);
begin.
Form2.Show;
end;
procedure TForm3. N3Click (Sender: TObject);
begin.
Form1.close;
Form2.Close;
Form3.Close;
Form4.Close;
Form5.Close;
Form6.Close;
end;
procedure TForm3. N5Click (Sender: TObject);
begin.
Form4.Show;
end;
procedure TForm3. N6Click (Sender: TObject);
begin.
Form5.Show;
end;
procedure TForm3. N7Click (Sender: TObject);
begin.
Form6.Show;
end;
procedure TForm3. N4Click (Sender: TObject);
begin.
Form1.Show;
Form3.Hide;
end;
procedure TForm3. N2Click (Sender: TObject);
begin.
Form9.Show;
end;
end.
unit Unit4;
interface.
uses.
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,.
Dialogs, StdCtrls, Buttons, Menus;
type.
TForm4 = class (TForm).
BitBtn1: TBitBtn;
Memo1: TMemo;
Memo2: TMemo;
Label1: TLabel;
BitBtn2: TBitBtn;
BitBtn3: TBitBtn;
MainMenu1: TMainMenu;
N1: TMenuItem;
N2: TMenuItem;
N3: TMenuItem;
N4: TMenuItem;
N5: TMenuItem;
N6: TMenuItem;
N7: TMenuItem;
procedure BitBtn1Click (Sender: TObject);
procedure BitBtn2Click (Sender: TObject);
procedure BitBtn3Click (Sender: TObject);
procedure N2Click (Sender: TObject);
procedure N3Click (Sender: TObject);
procedure N4Click (Sender: TObject);
procedure N5Click (Sender: TObject);
procedure N6Click (Sender: TObject);
procedure N7Click (Sender: TObject);
private.
{ Private declarations }.
public.
{ Public declarations }.
end;
var.
Form4: TForm4;
x, y, i, k1, k2:integer; r, p: real; st: string;
implementation.
uses Unit1, Unit2, Unit3, Unit5, Unit6;
{$R *.dfm}.
procedure TForm4. BitBtn1Click (Sender: TObject);
begin.
Form1.close;
Form2.Close;
Form3.Close;
Form4.Close;
end;
procedure TForm4. BitBtn2Click (Sender: TObject);
begin.
Form1.Show;
Form4.Hide;
end;
procedure TForm4. BitBtn3Click (Sender: TObject);
begin.
randomize; k1:=0;
with form4. Canvas do begin.
for i:=1 to 200 000 do begin.
x:=random (300);
y:=random (300);
r:=sqrt ((x-150)*(x-150)+(y-150)*(y-150));
if r<=150 then begin.
Pixels[x+30, y+30]: =$ 00FF;
inc (k1);
end.
Else.
begin.
Pixels[x+30, y+30]: =$ 00FF0000;
end;
end;
p:=4*k1/200 000;
str (p, st);
TextOut (10, 300, st);
end;
end;
procedure TForm4. N2Click (Sender: TObject);
begin.
Form1.close;
Form2.Close;
Form3.Close;
Form4.Close;
Form5.Close;
Form6.Close;
end;
procedure TForm4. N3Click (Sender: TObject);
begin.
Form1.Show;
Form4.Hide;
end;
procedure TForm4. N4Click (Sender: TObject);
begin.
Form2.Show;
end;
procedure TForm4. N5Click (Sender: TObject);
begin.
Form3.Show;
end;
procedure TForm4. N6Click (Sender: TObject);
begin.
Form5.Show;
end;
procedure TForm4. N7Click (Sender: TObject);
begin.
Form6.Show;
end;
end.
unit Unit5;
interface.
uses.
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,.
Dialogs, Math, StdCtrls, ExtCtrls, Buttons, Menus;
type.
TForm5 = class (TForm).
Image1: TImage;
Edit1: TEdit;
Edit2: TEdit;
Label1: TLabel;
Label2: TLabel;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
MainMenu1: TMainMenu;
N1: TMenuItem;
N2: TMenuItem;
N3: TMenuItem;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
BitBtn3: TBitBtn;
BitBtn4: TBitBtn;
N4: TMenuItem;
N5: TMenuItem;
N6: TMenuItem;
N7: TMenuItem;
N8: TMenuItem;
procedure BitBtn1Click (Sender: TObject);
procedure BitBtn2Click (Sender: TObject);
procedure Edit1KeyPress (Sender: TObject; var Key: Char);
procedure Edit1KeyDown (Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure BitBtn3Click (Sender: TObject);
procedure N2Click (Sender: TObject);
procedure BitBtn4Click (Sender: TObject);
procedure N4Click (Sender: TObject);
procedure N5Click (Sender: TObject);
procedure N6Click (Sender: TObject);
procedure N7Click (Sender: TObject);
procedure N8Click (Sender: TObject);
procedure N3Click (Sender: TObject);
private.
{ Private declarations }.
public.
{ Public declarations }.
end;
var.
Form5: TForm5;
R: integer; //ΡΠ°Π΄ΠΈΡΡ.
N: integer; //ΠΊΠΎΠ»ΠΈΡΠ΅ΡΡΠ²ΠΎ «Π±ΡΠΎΡΠ΅Π½Π½ΡΡ » ΡΠΎΡΠ΅ΠΊ.
X: real; //ΠΊΠΎΠΎΡΠ΄ΠΈΠ½Π°ΡΠ° ΡΠΎΡΠ΅ΠΊ X.
Y: real; //ΠΊΠΎΠΎΡΠ΄ΠΈΠ½Π°ΡΠ° ΡΠΎΡΠ΅ΠΊ Y.
M: integer; //ΠΊΠΎΠ»ΠΈΡΠ΅ΡΡΠ²ΠΎ ΡΠΎΡΠ΅ΠΊ, ΠΏΠΎΠΏΠ°Π²ΡΠΈΡ .
I: integer;
implementation.
uses Unit1, Unit2, Unit3, Unit4, Unit10, Unit6;
{$R *.dfm}.
procedure TForm5. BitBtn1Click (Sender: TObject);
begin.
//Π‘ΡΠΈΡΠ°Π½ΠΈΠ΅.
Image1.Canvas.Brush.Color := clWhite;
Image1.Canvas.Rectangle (100-R, 100-R, 100+R, 100+R); Image1.Canvas.FillRect (Rect (100-R, 100-R, 100+R, 100+R));
M:=0;
//ΠΠ²ΠΎΠ΄ Π·Π½Π°ΡΠ΅Π½ΠΈΠΉ.
R:=StrToInt (Edit1.Text);
N:=StrToInt (Edit2.Text);
//Π ΠΈΡΠΎΠ²Π°Π½ΠΈΠ΅ ΠΊΠ²Π°Π΄ΡΠ°ΡΠ° ΠΈ ΠΊΡΡΠ³Π°.
Image1.Canvas.Rectangle (100-R, 100-R, 100+R, 100+R); Image1.Canvas.Ellipse (100-R, 100-R, 100+R, 100+R); //ΠΠ΅Π½Π΅ΡΠ°ΡΠΈΡ ΡΠΎΡΠ΅ΠΊ Randomize;
For I:=1 To N do begin.
X:=Random (2*R)-R;
Y:=Random (2*R)-R;
Image1.Canvas.Pixels[Round (X)+100,.
Round (Y)+100]: =clRed;
If Sqr (X)+Sqr (Y)<=Sqr®.
Then M:=M+1.
end;
//ΠΠ»ΠΎΡΠ°Π΄Ρ.
Label1.Caption:=FloatToStr (4*Sqr®*M/N);
//Π§ΠΈΡΠ»ΠΎ PI.
Label2.Caption:=FloatToStr (4*M/N);
end;
procedure TForm5. BitBtn2Click (Sender: TObject);
begin.
Image1.picture:=nil;
label1.caption:='ΠΡΠ²ΠΎΠ΄ Π·Π½Π°ΡΠ΅Π½ΠΈΠΉ ΠΏΠ»ΠΎΡΠ°Π΄ΠΈ ΠΊΡΡΠ³Π°';
label2.caption:='ΠΡΠ²ΠΎΠ΄ Π·Π½Π°ΡΠ΅Π½ΠΈΠΉ ΡΠΈΡΠ»Π° Pi';
end;
procedure TForm5. Edit1KeyPress (Sender: TObject; var Key: Char);
const.
D = ['0', '1', '5', #8];
begin.
if not (Key in D) then Key := #0;
end;
procedure TForm5. Edit1KeyDown (Sender: TObject; var Key: Word;
Shift: TShiftState);
begin.
if (ssShift in Shift) and (Key = VK_INSERT) then Abort;
end;
procedure TForm5. BitBtn3Click (Sender: TObject);
begin.
Form1.close;
Form2.Close;
Form3.Close;
Form4.Close;
Form5.Close;
end;
procedure TForm5. N2Click (Sender: TObject);
begin.
Form10.Show;
end;
procedure TForm5. BitBtn4Click (Sender: TObject);
begin.
Form1.Show;
Form5.Hide;
end;
procedure TForm5. N4Click (Sender: TObject);
begin.
Form1.Show;
Form5.Hide;
end;
procedure TForm5. N5Click (Sender: TObject);
begin.
Form2.Show;
end;
procedure TForm5. N6Click (Sender: TObject);
begin.
Form3.Show;
end;
procedure TForm5. N7Click (Sender: TObject);
begin.
Form4.Show;
end;
procedure TForm5. N8Click (Sender: TObject);
begin.
Form6.Show;
end;
procedure TForm5. N3Click (Sender: TObject);
begin.
Form1.close;
Form2.Close;
Form3.Close;
Form4.Close;
Form5.Close;
Form6.Close;
end;
end.
unit Unit6;
interface.
uses.
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,.
Dialogs, StdCtrls, Buttons, Menus, ExtCtrls;
type.
TForm6 = class (TForm).
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
Edit1: TEdit;
Edit2: TEdit;
BitBtn3: TBitBtn;
BitBtn4: TBitBtn;
BitBtn5: TBitBtn;
MainMenu1: TMainMenu;
N1: TMenuItem;
N2: TMenuItem;
N3: TMenuItem;
Panel1: TPanel;
Panel2: TPanel;
BitBtn6: TBitBtn;
N4: TMenuItem;
N5: TMenuItem;
N6: TMenuItem;
N7: TMenuItem;
N8: TMenuItem;
procedure BitBtn3Click (Sender: TObject);
procedure BitBtn1Click (Sender: TObject);
procedure BitBtn2Click (Sender: TObject);
procedure BitBtn4Click (Sender: TObject);
procedure BitBtn5Click (Sender: TObject);
procedure N3Click (Sender: TObject);
procedure BitBtn6Click (Sender: TObject);
procedure N2Click (Sender: TObject);
procedure N4Click (Sender: TObject);
procedure N5Click (Sender: TObject);
procedure N6Click (Sender: TObject);
procedure N7Click (Sender: TObject);
procedure N8Click (Sender: TObject);
private.
{ Private declarations }.
public.
{ Public declarations }.
end;
var.
Form6: TForm6;
N: integer;
M: integer;
implementation.
uses Unit1, Unit2, Unit3, Unit4, Unit5, Unit11;
{$R *.dfm}.
procedure TForm6. BitBtn3Click (Sender: TObject);
var x0, y0, y, a: real;
b, k, i, c: integer;
begin.
Randomize;
k:=0;
c:= strtoint (Form6.Edit2.Text);
For i:=1 to c do.
begin.
x0:=Random (100)+250;
//a:=round ((x0−250)/10);
a:=(x0−250)/10;
y0:=250 — a*a;
y:=Random (100)+ 150;
If y.
begin.
k:=k+1;
Canvas.Pixels [round (x0), round (y)]: =clNavy;
end;
end;
N:=k;
M:=c;
end;
procedure TForm6. BitBtn1Click (Sender: TObject);
var.
a:integer;
b: integer;
x0, y0: real;
x, y: real;
begin.
with Canvas do.
begin.
TextOut (250, 35, 'y'); // Π½Π°Π΄ΠΏΠΈΡΡ ΠΎ…