Ответ:
1.
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Spin;
const
n = 4;
type
TFormT = class(TForm)
Button1: TButton;
Memo1: TMemo;
Label1: TLabel;
procedure Button1Click(Sender: TObject);
private
b: array[0..n-1, 0..n-1] of integer;
procedure FillArray;
public
end;
var
FormT: TFormT;
implementation
{$R *.dfm}
{ TForm2 }
procedure TFormT.Button1Click(Sender: TObject);
begin
memo1.Clear;
Label1.Caption := '';
FillArray;
procedure TFormT.FillArray;
i, j, S : Integer;
P : Longint;
st : string;
randomize;
P:=1;
S:=0;
for i:=0 to n-1 do begin
st:='';
for j:=0 to n-1 do begin
b[i, j]:= 1+ Random(10);
st := st + format('%2d ',[b[i, j]]);
if b[i, j] mod 2 <> 0 then begin
P := P * b[i, j];
S := S + b[i, j];
Memo1.Lines.Add(st);
Label1.Caption :='Произведение=' + inttostr(p) +' Сумма=' + inttostr(s);
end.
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
Ответ:
1.
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Spin;
const
n = 4;
type
TFormT = class(TForm)
Button1: TButton;
Memo1: TMemo;
Label1: TLabel;
procedure Button1Click(Sender: TObject);
private
b: array[0..n-1, 0..n-1] of integer;
procedure FillArray;
public
end;
var
FormT: TFormT;
implementation
{$R *.dfm}
{ TForm2 }
procedure TFormT.Button1Click(Sender: TObject);
begin
memo1.Clear;
Label1.Caption := '';
FillArray;
end;
procedure TFormT.FillArray;
var
i, j, S : Integer;
P : Longint;
st : string;
begin
randomize;
P:=1;
S:=0;
for i:=0 to n-1 do begin
st:='';
for j:=0 to n-1 do begin
b[i, j]:= 1+ Random(10);
st := st + format('%2d ',[b[i, j]]);
if b[i, j] mod 2 <> 0 then begin
P := P * b[i, j];
S := S + b[i, j];
end;
end;
Memo1.Lines.Add(st);
end;
Label1.Caption :='Произведение=' + inttostr(p) +' Сумма=' + inttostr(s);
end;
end.