Вы находитесь на странице: 1из 4

1.

2. -11-08
3. 3
4. 3
5. - . , D,
.
6. .
7.

8. :

Form1

OnCreate

9. , :

procedure
TForm1.Button1Click
procedure
TForm2.N2Click
procedure
TForm2.N3Click
procedure
TForm2.N4Click
procedure
TForm2.N5Click



.
.

10.

/
/
- /
- /
- /
/

()

()

real

rast

real

Integer

Integer
shar

shar

shar

()

i
x

F
Ff

11. ,

12.

13. ( .dpr)
14. (.pas)

unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Menus, Grids, StdCtrls;
type
TForm1 = class(TForm)
StringGrid1: TStringGrid;
OpenDialog1: TOpenDialog;
SaveDialog1: TSaveDialog;
MainMenu1: TMainMenu;
N1: TMenuItem;
N2: TMenuItem;
N3: TMenuItem;
N4: TMenuItem;
N5: TMenuItem;
Button1: TButton;
Edit1: TEdit;
Edit2: TEdit;

Edit3: TEdit;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure N2Click(Sender: TObject);
procedure N4Click(Sender: TObject);
procedure N3Click(Sender: TObject);
procedure N5Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
type shar=record x,y:integer; r:real; end;
var f:file of shar; ff:textfile; d:real; x:shar;
{$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';
stringgrid1.Cells[3,0]:='R';
end;
procedure TForm1.Button1Click(Sender: TObject);
var i,k:integer; rast:real;
begin
d:=strtofloat(edit2.Text);
rast:=0;
k:=0;
for i:=1 to strtoint(edit1.Text) do
begin
x.x:=strtoint(stringgrid1.Cells[1,i]);
x.y:=strtoint(stringgrid1.Cells[2,i]);
x.r:=strtofloat(stringgrid1.Cells[3,i]);
if (3.14*sqr(x.r))<d then
if rast<(sqrt(sqr(x.x)+sqr(x.y))) then begin
k:=i;
rast:=sqrt(sqr(x.x)+sqr(x.y));
end;
end;
if k=0 then
edit3.Text:=' '+floattostr(d)+''
else
edit3.Text:=' '+floattostr(k)+' ('+floattostr(rast)+')';
end;
procedure TForm1.N2Click(Sender: TObject);
var i:integer;
begin
if SaveDialog1.Execute then
begin
AssignFile(f,SaveDialog1.FileName);
Rewrite(f);
for i:=1 to strtoint(edit1.Text) do
begin
x.x:=strtoint(stringgrid1.Cells[1,i]);
x.y:=strtoint(stringgrid1.Cells[2,i]);
x.r:=strtoint(stringgrid1.Cells[3,i]);
write(f,x);
end;
Closefile(f);
end;
end;
procedure TForm1.N4Click(Sender: TObject);
var i:integer;
begin
if OpenDialog1.Execute then
begin
if FileExists(OpenDialog1.FileName) then
begin
AssignFile(f,OpenDialog1.FileName);
Reset(f);
edit1.text:=floattostr(filesize(f));
for i:=1 to strtoint(edit1.Text) do
begin
read(f,x);
stringgrid1.Cells[1,i]:=floattostr(x.x);
stringgrid1.Cells[2,i]:=floattostr(x.y);
stringgrid1.Cells[3,i]:=floattostr(x.r);

end;
end;
end;
end;
procedure TForm1.N3Click(Sender: TObject);
var i:integer;
begin
if SaveDialog1.Execute then
begin
AssignFile(ff,SaveDialog1.FileName);
Rewrite(ff);
for i:=1 to strtoint(edit1.Text) do
begin
x.x:=strtoint(stringgrid1.Cells[1,i]);
write(ff, x.x, ' ');
x.y:=strtoint(stringgrid1.Cells[2,i]);
write(ff,x.y, ' ');
x.r:=strtoint(stringgrid1.Cells[3,i]);
writeln(ff,x.r, ' ');
end;
Closefile(ff);
end;
end;
procedure TForm1.N5Click(Sender: TObject);
var i,n:integer;
begin
n:=0;
if OpenDialog1.Execute then
begin
if FileExists(OpenDialog1.FileName) then
begin
AssignFile(ff,OpenDialog1.FileName);
Reset(ff);
while not EOF(ff) do begin readln(ff); n:=n+1; end;
Closefile(ff); Reset(ff);
edit1.Text:=floattostr(n);
for i:=1 to n do
begin
readln(ff, x.x, x.y, x.r);
stringgrid1.Cells[1,i]:=floattostr(x.x);
stringgrid1.Cells[2,i]:=floattostr(x.y);
stringgrid1.Cells[3,i]:=floattostr(x.r);
end;
end;
end;
end;
end.