06.12.2017, 07:59
|
Прохожий
|
|
Регистрация: 06.12.2017
Сообщения: 1
Версия Delphi: Delphi 12
Репутация: 10
|
|
ПОМОГИТЕ пожалуйста составить ЛЕГКУЮ блок схему по коду - Delphi
Программа строит матрицы из рандомных составляющих,строки и столбцы заданы.
Так же определяется сумма всех элементов в строках и столбцах,помогите,очень важно!
Код:
unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.Grids, Vcl.StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Label1: TLabel;
Edit1: TEdit;
Label2: TLabel;
Edit2: TEdit;
StringGrid1: TStringGrid;
Label3: TLabel;
StringGrid2: TStringGrid;
procedure Edit2Change(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
N,M:integer;
S:double;
i,j:integer;
A:array of array of double;
implementation
{$R *.dfm}
procedure TForm1.Edit2Change(Sender: TObject);
var
i,j:integer;
begin
N:=StrToInt(Edit1.Text);
M:=StrToInt(Edit2.Text);
SetLength(A,N+1,M+1); // Динамическое распределение памяти(выделение памяти ПК для файлов в программе)
StringGrid1.RowCount:=N+1; // Строки
StringGrid1.ColCount:=M+1; // Столбцы
for i := 1 to N do
StringGrid1.Cells[0,i]:='i='+IntToStr(i); // Клетки
for i := 1 to M do
StringGrid1.Cells[i,0]:='j='+IntToStr(i);
for i := 1 to N do
for j := 1 to M do
StringGrid1.Cells[j,i]:=IntToStr(Random(10)); // Случайное число от 0-9
for i := 1 to N do
for j := 1 to M do
A[i,j]:=StrToFloat(StringGrid1.Cells[j,i]);
// Вычисления суммы элементов матриц
S:=0;
for i := 1 to N do
for j := 1 to M do
S:=S+A[i,j];
Label3.Caption:='Сумма элементов S='+FloatToStr(S);
StringGrid2.RowCount:=N+1;
for i := 1 to N do begin
StringGrid2.Cells[1,0]:='J Столбцов';
S:=0;
for j := 1 to M do S:=s+A[i,j];
StringGrid2.Cells[0,i]:=FloatToStr(S);
end;
StringGrid2.ColCount:=2;
for i := 1 to N do begin
StringGrid2.Cells[0,0]:='I Строк';
S:=0;
for j := 1 to M do S:=s+A[j,i];
StringGrid2.Cells[1,i]:=FloatToStr(S);
end;
end;
end.
|