unit mat; interface type radek=array of integer; amatice=array of radek; matice=class data:amatice; m,n:integer; constructor Init(a:amatice);overload; constructor Init(m,n:integer);overload; function pricti(b:matice):matice; function prinasob(b:matice):matice; procedure generate; procedure vypis; end; implementation constructor Matice.Init(a:amatice); begin Init(length(a),length(a[0])); data:=a; end; constructor Matice.Init(m,n:integer); begin self.m:=m; self.n:=n; setlength(data,m,n); end; function Matice.pricti(b:matice):matice; var i,j:integer; c:Matice; begin C:=Matice.Init(m,n); if (b.m=m) and (b.n = n) then begin for i:=low(data) to high(data) do for j:=low(data[i]) to high(data[i]) do c.data[i,j]:=data[i,j]+b.data[i,j]; end; pricti:=c; end; function Matice.prinasob(b:matice):matice; var i,j,k:integer; c:matice; begin c:=Matice.Init(length(data),length(b.data[0])); if b.m=n then begin for i:=0 to m-1 do for j:=0 to b.n-1 do begin c.data[i,j]:=0; for k:=0 to n-1 do c.data[i,j]:=c.data[i,j]+data[i,k]*b.data[k,j]; end; end; prinasob:=c; end; procedure matice.generate; var i,j:integer; begin randomize; for i:=0 to m-1 do for j:=0 to n-1 do data[i,j]:=random(3); end; procedure matice.vypis; var i,j:integer; begin for i:=0 to m-1 do begin for j:=0 to n-1 do write(data[i,j]:4); writeln; end; end; end.