Будьте так добры. Используя директиву absolute, создать построчно с помощью
подпрограммы матрицы 5х5 и 2х3.
program matr;
procedure MatrA(var z);
var
MasA:array [1..5,1..5] of integer absolute z;
i,j:integer;
begin
for i:=1 to 5 do
for j:=1 to 5 do
MasA[i,j]:=Random(10);
for i:=1 to 5 do
begin
for j:=1 to 5 do
write(masA[i,j], ' ');
end;
end;
procedure MatrB(var t);
var
MasB:array [1..2,1..3] of integer absolute t;
i,j:integer;
begin
for i:=1 to 2 do
for j:=1 to 3 do
MasB[i,j]:=Random(10);
for i:=1 to 2 do
begin
for j:=1 to 3 do
write(MasB[i,j] , ' ');
end;
end;
var
x:array [1..5,1..5] of integer;
y:array [1..2,1..3] of integer;
begin
writeln('matrix A 5*5');
writeln('----------------------------');
MatrA(x);
writeln('matrix B 2*3');
writeln('----------------------------');
MatrB(y);
readln
end.
М | Тэги! |
program Matrix;
procedure FillMatrix(var Matrix; n,m: integer);
var
x: array [1..$7FF0] of integer absolute Matrix; {примерно максимальный размер массива в TP/BP}
i,j: integer;
begin
for i:=1 to n do
for j:=1 to m do
x[(i-1)*m+j]:=Random(10) {вручную пересчитываем индексы}
end;
procedure ShowMatrix(var Matrix; n,m: integer);
var
x: array [1..$7FF0] of integer absolute Matrix;
i,j: integer;
begin
for i:=1 to n do begin
for j:=1 to m do write(x[(i-1)*m+j]:4);
WriteLn
end
end;
var
A: array [1..5,1..5] of integer;
B: array [1..2,1..3] of integer;
begin
writeln('matrix A 5*5');
writeln('----------------------------');
FillMatrix(A,5,5);
ShowMatrix(A,5,5);
WriteLn;
writeln('matrix B 2*3');
writeln('----------------------------');
FillMatrix(B,2,3);
ShowMatrix(B,2,3);
readln
end.