unit
UnProt;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TFMain =
class
(TForm)
BTInput: TButton;
BTexit: TButton;
Memo1: TMemo;
OD1: TOpenDialog;
Label1: TLabel;
Label2: TLabel;
procedure
BTexitClick(Sender: TObject);
procedure
BTInputClick(Sender: TObject);
private
public
end
;
type
TMatrix =
Array
of
Array
of
real
;
var
FMain: TFMain;
implementation
{$R *.dfm}
procedure
TFMain
.
BTexitClick(Sender: TObject);
begin
if
(messagedlg(
'Вы действительно хотите выйти?'
,mtconfirmation,[mbYes,mbNo],
0
)=mryes)
then
close;
end
;
procedure
TFMain
.
BTInputClick(Sender: TObject);
var
M: TMatrix;
summ:
real
;
F: TextFile;
c:
Char
;
i, j:
Integer
;
s:
string
;
begin
if
od1
.
Execute
then
AssignFile(F,od1
.
filename);
Reset(F);
j :=
0
;
i :=
0
;
summ:=
0
;
while
not
Eof(F)
do
begin
j :=
0
;
while
not
Eoln(F)
do
begin
SetLength(M, i +
1
);
SetLength(M[i], j +
1
);
Read(F, M[i, j]);
j := j +
1
;
end
;
Read(F, c);
i := i +
1
;
end
;
memo1
.
visible:=
true
;
for
i :=
0
to
Length(M) -
1
do
begin
for
j :=
0
to
Length(M[i]) -
1
do
begin
S := S + floatToStr(M[i, j]) +
' '
;
summ:=summ+M[i, j];
end
;
S := S + #
13
#
10
;
end
;
memo1
.
Lines
.
Add(s);
memo1
.
Lines
.
Add((
'Сумма элементов матрицы='
+floattostr(summ)));
end
;
end
.