You are on page 1of 5

1.

2. -11-08
3. 3
4. 4
5. - . 4
, - 1- ,

6. 3
.
7.

8. :

Form1
Form1

OnCreate
OnClose

9. , :

procedure
TForm1.Button1Click
procedure
Tform3.Button1Click
procedure
Tform4.Button1Click
function kol

- 1

function chetv
function sum

10.

/
/
- /
- /
- /
/

()

Tochka

Integer

Integer

()

i
r
o
x

Real
Tochka
Tochka

11. ,

12.

13. ( .dpr)
14. (.pas)
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Grids, Unit2;
type
TForm1 = class(TForm)
StringGrid1: TStringGrid;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses Unit3, Unit4;
var t:array[1..7] of tochka;
o:tochka; r:real;
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
var i:integer;
begin
for i:=1 to 7 do
stringgrid1.cells[0,i]:=' '+floattostr(i);
stringgrid1.cells[1,0]:='X';
stringgrid1.cells[2,0]:='Y';
end;
procedure TForm1.Button1Click(Sender: TObject);
var i,n:integer;
begin
n:=strtoint(edit4.Text);
o.x:=strtoint(edit1.Text);
o.y:=strtoint(edit2.Text);
r:=strtofloat(edit3.Text);
for i:=1 to n do
begin
t[i].x:=strtoint(stringgrid1.cells[1,i]);
t[i].y:=strtoint(stringgrid1.cells[2,i]);
end;
if kol(t,o,r,n)>4 then
begin
form3.show;
form3.label1.caption:=' 1 '+floattostr(chetv(t,n))+' ';
end
else
form4.show;
form4.label1.caption:=' '+floattostr(sum(t,n));
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
form3.close;
form4.close;
end;
end.
unit Unit2;
interface
type tochka=record x,y:integer; end;
function kol(b:array of tochka; o:tochka; r:real; n:integer):integer;
function chetv(b:array of tochka; n:integer):integer;
function sum(b:array of tochka; n:integer):real;
implementation

function kol(b:array of tochka; o:tochka; r:real; n:integer):integer;


var i:integer;
begin
result:=0;
for i:=0 to n-1 do
if sqrt(sqr(o.x-b[i].x)+sqr(o.y-b[i].y))<=r then
result:=result+1;
end;
function chetv(b:array of tochka; n:integer):integer;
var i:integer;
begin
result:=0;
for i:=0 to n-1 do
if (b[i].x>0)and(b[i].y>0) then
result:=result+1;
end;
function sum(b:array of tochka; n:integer):real;
var i:integer;
begin
result:=0;
for i:=0 to n-1 do
result:=result+sqrt(sqr(b[i].x)+sqr(b[i].y));
end;
end.
unit Unit3;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm3 = class(TForm)
Button1: TButton;
Label1: TLabel;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form3: TForm3;
implementation
uses Unit1;
{$R *.dfm}
procedure TForm3.Button1Click(Sender: TObject);
begin
form1.show;
hide;
end;
end.
unit Unit4;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm4 = class(TForm)
Label1: TLabel;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form4: TForm4;

implementation
uses Unit1;
{$R *.dfm}
procedure TForm4.Button1Click(Sender: TObject);
begin
form1.show;
hide;
end;
end.