Примерно так (массив задаю случайными целыми числами):
| Код | unit Unit1;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;
type TForm1 = class(TForm) Button1: TButton; Label1: TLabel; Label2: TLabel; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; const m = 5; var Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject); var i, j: Integer; a: array[1..m,1..m] of Integer; begin Label1.Caption:=''; Label2.Caption:=''; // zadaem massiv a randomize; for i:=1 to m do begin for j:=1 to m do begin a[i,j]:=Random(10); Label1.Caption:=Label1.Caption+IntToStr(a[i,j])+#9; end; Label1.Caption:=Label1.Caption+#13; end;
// obrabotka massiva a for i:=1 to m do for j:=1 to m do if i>=m-j+1 then // uslovie pobochoy diagonali a[i,j]:=0;
// vivod obrabotanogo massiva a for i:=1 to m do begin for j:=1 to m do Label2.Caption:=Label2.Caption+IntToStr(a[i,j])+#9; Label2.Caption:=Label2.Caption+#13; end; end;
end.
|
|