Ответ:
2.
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Spin;
const
n = 5;
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 FillArray2;
public
end;
var
FormT: TFormT;
implementation
{$R *.dfm}
{ TForm2 }
procedure TFormT.Button1Click(Sender: TObject);
begin
memo1.Clear;
Label1.Caption := '';
FillArray2;
procedure TFormT.FillArray2;
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]:= -n + Random(2*n+1);
st := st + format('%2d ',[b[i, j]]);
Memo1.Lines.Add(st);
Memo1.Lines.Add('---------------------------------');
if i=j then
if b[i, j] < 0 then b[i, j] := 2
else b[i, j] := 4;
Объяснение:
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
Ответ:
2.
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Spin;
const
n = 5;
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 FillArray2;
public
end;
var
FormT: TFormT;
implementation
{$R *.dfm}
{ TForm2 }
procedure TFormT.Button1Click(Sender: TObject);
begin
memo1.Clear;
Label1.Caption := '';
FillArray2;
end;
procedure TFormT.FillArray2;
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]:= -n + Random(2*n+1);
st := st + format('%2d ',[b[i, j]]);
end;
Memo1.Lines.Add(st);
end;
Memo1.Lines.Add('---------------------------------');
for i:=0 to n-1 do begin
st:='';
for j:=0 to n-1 do begin
if i=j then
if b[i, j] < 0 then b[i, j] := 2
else b[i, j] := 4;
st := st + format('%2d ',[b[i, j]]);
end;
Memo1.Lines.Add(st);
end;
end;
Объяснение: