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);
i:=1;
while i<=m do
begin
j:=1;
repeat
a[i,j]:=random(6)-1;
write(a[i,j]:3);
j:=j+1;
until j>n;
writeln;
i:=i+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);
j:=1;
while j<=n do
begin
k:=1;
repeat
b[j,k]:=random(6)-1;
write(b[j,k]:3);
k:=k+1;
until k>p;
writeln;
j:=j+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 k:=1 to p do
begin
c[i,k]:=0;
for j:=1 to n do
begin
c[i,k]:=a[i,j]*b[j,k]+c[i,k];
end;
write (c[i,k]:4);
end;
writeln;
end;
end;
Var
m,n,p:integer;
a,b,c:TMatrix;
Begin
TM(m,n,a);
TM1(n,p,b);
writeln;
ymnog(m,n,p,a,b,c);
readln;
End.