Ahoj, morduji se s problemem, ohledne funkci numberOfColumns a numberOfRows, ty sice pocitaji co maji, avsak uz se pozadovane hodnoty (m) a (n) nevrati jako globalne premenne (tzn. vo funkcii bezi vsechno tak jak ma, pri prechadzeni numberOfRows se nakonci napr. m=3, avsak pote co se skonci telo funkce, se m znovu nastavi na 0)
Mozno mam problem nekde u definovani funkce etc. nevim. Tipy uvitam. Diki :)
cast kodu:
function numberOfRows(m:integer):integer;
begin
clrscr;
writeln('Put the size of matrix');
writeln;
write('Number of row: ');
readln(m);
numberOfRows:=m;
end;
function numberOfColumns(n:integer):integer;
begin
write('Number of columns: ');
readln(n);
numberOfColumns:=n;
end;
procedure readInput;
begin
if areTwoMatrix= false then
begin
numberOfRows(m);
numberOfColumns(n);
m1:=m;
n1:=n;
clrscr;
writeln('Write the first matrix: ');
writeln;
for i:=1 to m1 do
for j:=0 to n1 do
read(a[i,j]);
end;
if areTwoMatrix= true then
begin
if isSizeOfMatrixTheSame=true then
begin
m2:=m1;
n2:=n1;
end
else
begin
numberOfRows(m);
numberOfColumns(n);
clrscr;
m2:=m;
n2:=n;
end;
writeln('Write the second matrix');
writeln;
for i:=1 to m2 do
for j:=0 to n2 do
read(b[i,j]);
end;
end;
procedure plus;
begin
areTwoMatrix:=false;
readInput;
areTwoMatrix:=true;
isSizeOfMatrixTheSame:=true;
readInput;
clrscr;
writeln('Matrix A + matrix B = ');
writeln;
for i:=1 to m1 do
begin
for j:=1 to n1 do
begin
c[i,j]:=a[i,j]+b[i,j];
write(c[i,j],' ');
end;
writeln;
end;
end;