unit
Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Buttons, StdCtrls, Grids;
type
TForm1 =
class
(TForm)
StringGrid1: TStringGrid;
Edit1: TEdit;
SpeedButton1: TSpeedButton;
SpeedButton2: TSpeedButton;
Edit2: TEdit;
BitBtn1: TBitBtn;
Label1: TLabel;
Edit3: TEdit;
Button2: TButton;
Label2: TLabel;
procedure
SpeedButton1Click(Sender: TObject);
procedure
FormCreate(Sender: TObject);
procedure
SpeedButton2Click(Sender: TObject);
procedure
BitBtn1Click(Sender: TObject);
procedure
Button2Click(Sender: TObject);
private
public
end
;
type
zap=
record
NZ :
string
[
6
];
fam: s15;
ball:
array
[
1..3
]
of
integer
;
end
;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure
TForm1
.
FormCreate(Sender: TObject);
begin
with
StringGrid1
do
begin
Cells[
0
,
0
] :=
'№/№'
;
Cells[
1
,
0
] :=
'Фамилия'
;
Cells[
2
,
0
] :=
'Математика'
;
Cells[
3
,
0
] :=
'Физика'
;
Cells[
4
,
0
] :=
'Химия'
;
Cells[
5
,
0
] :=
'Средний балл'
;
ColCount:=
6
; FixedCols:=
0
;
end
;
end
;
procedure
TForm1
.
SpeedButton1Click(Sender: TObject);
Var
I,j :
Byte
;
F :
File
of
Zap;
S : zap;
begin
AssignFile(F, Edit1
.
Text);
Rewrite(F);
StringGrid1
.
RowCount:=StrToInt(Edit3
.
text);
For
I :=
1
to
StringGrid1
.
RowCount-
1
do
with
StringGrid1
do
Begin
S
.
NZ := Cells[
0
,I];
S
.
fam := Cells[
1
,I];
S
.
ball[
1
]:=StrToInt( Cells[
2
,I]);
S
.
ball[
2
]:=StrToInt( Cells[
3
,I]);
S
.
ball[
3
]:=StrToInt( Cells[
4
,I]);
Write
(F,S)
end
;
CloseFile(F)
end
;
procedure
TForm1
.
SpeedButton2Click(Sender: TObject);
Var
I :
Byte
;
F :
File
of
Zap;
S : zap; Sr:
real
;
begin
AssignFile(F, Edit2
.
Text);
Reset(F); i:=
1
; seek(F,
0
);
while
not
eof(F)
do
Begin
read(F,S);
StringGrid1
.
Cells[
0
,I]:=S
.
NZ;
StringGrid1
.
Cells[
1
,I]:=S
.
fam;
StringGrid1
.
Cells[
2
,I]:=IntToStr(S
.
ball[
1
]);
StringGrid1
.
Cells[
3
,I]:=IntToStr(S
.
ball[
2
]);
StringGrid1
.
Cells[
4
,I]:=IntToStr(S
.
ball[
3
]);
SR:=(S
.
ball[
1
]+S
.
ball[
2
]+S
.
ball[
3
])/
3
;
StringGrid1
.
Cells[
5
,I]:=FloatToStrF(SR,ffFixed,
4
,
1
);
i:=i+
1
;
end
;
CloseFile(F)
end
;
procedure
TForm1
.
BitBtn1Click(Sender: TObject);
begin
Close;
end
;
procedure
TForm1
.
Button2Click(Sender: TObject);
var
i:
integer
;
begin
for
i:=
1
to
StringGrid1
.
RowCount
do
begin
StringGrid1
.
Cells[
0
,I]:=
' '
;
StringGrid1
.
Cells[
1
,I]:=
' '
;
StringGrid1
.
Cells[
2
,I]:=
' '
;
StringGrid1
.
Cells[
3
,I]:=
' '
;
StringGrid1
.
Cells[
4
,I]:=
' '
;
StringGrid1
.
Cells[
5
,I]:=
' '
;
end
;
end
;
end
.