program Project2;
{$APPTYPE CONSOLE}
uses
SysUtils;
type TMatrix=array[1..100,1..100] of integer;
procedure TM(Var m,n:integer; Var a:TMatrix);
var
i,j:integer;
begin
randomize;
writeln ('kol-vo strok: ');
readln(m);
writeln ('kol-vo stolbcov: ');
readln(n);
j:=1;
while j<=n do
begin
i:=1;
repeat
a[i,j]:=random(6)-1;
write(a[i,j]:3);
i:=i+1;
until i>m;
writeln;
j:=j+1;
end;
end;
procedure TM1(n:integer; var p:integer; Var b:TMatrix);
var
j,k:integer;
begin
randomize;
writeln ('kol-vo stolbcov: ');
readln(p);
k:=1;
while k<=p do
begin
j:=1;
repeat
b[j,k]:=random(6)-1;
write(b[j,k]:3);
j:=j+1;
until j>n;
writeln;
k:=k+1;
end;
end;
procedure ymnog(m,n,p:integer; a,b:TMatrix; Var c:TMatrix);
var
i,j,k:integer;
begin
for i:=1 to m do
begin
for j:=1 to n do
begin
c[i,k]:=0;
for k:=1 to p do
begin
c[i,k]:=a[i,j]*b[j,k]+c[i,k];
write (c[i,k]:4);
end;
writeln;
end;
end;
end;
Var
m,n,p:integer;
a,b,c:TMatrix;
Begin
TM(m,n,a);
TM1(n,p,b);
ymnog(m,n,p,a,b,c);
readln;
End.