//Pascal ABC.NET 3.1 сборка 1256
//Без ввода размерности
Const
n=3;
Var
ma1,ma2,mar:array[1..n,1..n] of integer;
i,j,z:integer;
begin
randomize;
writeln('Matrix 1:');
for i:=1 to n do
begin
for j:=1 to n do
begin
ma1[i,j]:=random(10);
write(ma1[i,j]:4);
end;
writeln;
end;
writeln('Matrix 2:');
for i:=1 to n do
begin
for j:=1 to n do
begin
ma2[i,j]:=random(10);
write(ma2[i,j]:4);
end;
writeln;
end;
writeln('Final matrix:');
for i:=1 to n do
begin
for j:=1 to n do
begin
for z:=1 to n do
mar[i,j]:=mar[i,j]+ma2[z,j]*ma1[i,z];
write(mar[i,j]:4);
end;
writeln;
end;
end.
//C вводом размерности
Var
ma1,ma2,mar:array[,] of integer;
i,j,z,n:integer;
begin
randomize;
readln(n);
setlength(ma1,n,n);
setlength(ma2,n,n);
setlength(mar,n,n);
writeln('Matrix 1:');
for i:=0 to n-1 do
begin
for j:=0 to n-1 do
begin
ma1[i,j]:=random(10);
write(ma1[i,j]:4);
end;
writeln;
end;
writeln('Matrix 2:');
for i:=0 to n-1 do
begin
for j:=0 to n-1 do
begin
ma2[i,j]:=random(10);
write(ma2[i,j]:4);
end;
writeln;
end;
writeln('Final matrix:');
for i:=0 to n-1 do
begin
for j:=0 to n-1 do
begin
for z:=0 to n-1 do
mar[i,j]:=mar[i,j]+ma2[z,j]*ma1[i,z];
write(mar[i,j]:4);
end;
writeln;
end;
end.