Я хочу вывести элементы массива, который заполняет пользователь. Вывод хочу организовать как матрицу. Проблема в том, что этого не происходит. Хотя, воде, по логике всё так. В чем может быть проблема?
Ввод:
Введите число строк 1-й матрицы - A (<=50)--> 2
Введите число столбцов 1-й матрицы - A (<=50)--> 2
Введите число столбцов 2-й матрицы - B (<=50)--> 2
Введите 1-ю матрицу (A):
Введите A[1,1] --> 1
Введите A[1,2] --> 2
Введите A[32,1] -->
Введите A[2,2] --> 4
Введите 2-ю матрицу (B):
Введите B[1,1] --> 5
Введите B[1,2] --> 6
Введите B[2,1] --> 6
Введите B[2,2] --> 6
Вывод:
Матрица А.
[1,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] [1,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]Матрица А.
[1,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] [3,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]Матрица А.
[3,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] [1,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]Матрица А.
[3,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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max] of Double;
ii,jj,kk,nn,mm,ll : integer; Summa: double;
begin
write('Введите число строк 1-й матрицы - A (<=50)--> ');readln(NN);
write('Введите число столбцов 1-й матрицы - A (<=50)--> ');readln(KK);
write('Введите число столбцов 2-й матрицы - B (<=50)--> ');readln(MM);
writeln('Введите 1-ю матрицу (A):');
for ii:=1 to nn do
for jj:=1 to kk do
begin
write('Введите A[',ii,',',jj,'] --> ');
readln(AA[ii,jj]);
end;
writeln('Введите 2-ю матрицу (B):');
for ii:=1 to kk do
for jj:=1 to mm do
begin write('Введите B[',ii,',',jj,'] --> '); readln(BB[ii,jj]);
end;
{проблема}
for ii:=1 to nn do
for jj:=1 to kk do
begin
writeln('Матрица А.');
write(AA[ii], ' ', AA[jj]);
end;
for ii:=1 to kk do
for jj:=1 to mm do
begin
writeln('Матрица B.');
write(BB[ii], ' ', BB[jj]);
end;
{Вычисляем элементы матрицы-результата}
for ii:=1 to nn do
for jj:=1 to mm do
begin
Summa:= 0;
for ll:= 1 to kk do
Summa:= Summa + AA[ii,ll]*BB[ll,jj];
CC[ii,jj] := Summa;
end;
{Выводим матрицу-результат:}
writeln();
writeln('---- Результат: -----');
for ii:=1 to nn do
begin
for jj:=1 to mm do
write(CC[ii,jj]:8:2);
writeln;
end;
readln;
end.