Zdravím, porsímvás, mám problém s domácím úkolem do Pascalu. Měla jsem napsat program, který mi sečte a vynásobí dvě matice zapsané ale jako array of array, čili ne klasických stylem matice. Problém je v tom, že program nejde spustit a nahlásí mi to exitcode, jsem už zoufalá, mohl by mi někdo pomoctt?:(
program matice_pro;
uses crt;
type TMatice = array of array of integer;
procedure setUp(var m: TMatice; x:integer; y:integer);
var c:array of integer;
i,j:integer;
begin
SetLength(m,x);
for i:=1 to x do
begin
SetLength(c,y);
for j:=1 to y do
begin
c[j]:=random(10);
end;
m[i]:=c;
finalize(c);
end;
end;
procedure print2D(const m : TMatice);
var i,j:integer;
c:array of integer;
begin
for i:=1 to Length(m) do
begin
c:=m[i];
for j:=1 to Length(c) do
begin
write(c[j]:5);
end;
writeln();
end;
writeln('-----------------------------------');
end;
function multiply(const m1 : TMatice; const m2 : TMatice): TMatice;
var b1,b2,b3: array of integer;
o,x,y,j,m:integer;
vys:Tmatice;
begin
x:=length(m1);
y:=length(m2);
setUp(vys,x,x);
writeln('vysledna matice ',x,'x',x);
for o:=1 to x do
begin
b1:=m1[o];
b3:=vys[o];
for j:=1 to x do
begin
b3[j]:=0;
for m:=1 to y do
begin
b2:=m2[m];
b3[j]:=b3[j]+b1[m]*b2[j];
{write(b1[m],'x',b2[j],'+');}
end;
{write(' =',b3[j]);
writeln;}
end;
vys[o]:=b3;
end;
multiply:=vys;
end;
function add(const m1 : TMatice; const m2 : TMatice): TMatice;
var m0:TMatice;
c,c1,c2:array of integer;
i,j:integer;
begin
setUp(m0,Length(m1),Length(m1[1]));
for i:=1 to Length(m1) do
begin
c:=m0[i];
c1:=m1[i];
c2:=m2[i];
for j:=1 to Length(c1) do
begin
c[j]:=c1[j]+c2[j];
end;
end;
add := m0;
end;
procedure finalize2D(var m: TMatice);
var c:array of integer;
i,x:integer;
begin
x:=length(m);
for i:=1 to x do
begin
c:=m[x];
finalize(c);
end;
finalize(m);
end;
var x,y:integer;
mat1,mat2,o,k:TMatice;
begin
randomize;
{ soucet matic }
x:=2+random(4);
y:=x;
setUp(mat1,x,y);
setUp(mat2,y,x);
print2d(mat1);
print2d(mat2);
o := add(mat1,mat2);
print2d(o);
finalize2D(o);
finalize2D(mat1);
finalize2D(mat2);
{ nasobeni matic}
x:=3;
y:=2;
setUp(mat1,x,y);
setUp(mat2,y,x);
print2d(mat1);
print2d(mat2);
k:=multiply(mat1,mat2);
print2D(k);
finalize2D(k);
finalize2D(mat1);
finalize2D(mat2);
readln;
end.