написать программу в паскале. даны квадратные матрицы а и в порядка n. получить матрицу ab-ba.
Answers & Comments
allangarsk
Var A,B: array [1..10,1..10] of integer; i, j, n: integer; begin Randomize;writeln('Введите размерность n');readln(n);writeln('Матрица А'); for i:=1 to n do begin for j:=1 to n do begin A[i,j]:= random(10)+1;write(A[i,j]:3);end;writeln;end; writeln('Матрица B'); for i:=1 to n do begin for j:=1 to n do begin B[i,j]:= random(10)+2;write(B[i,j]:3);end;writeln;end; writeln('Ответ: матрица AB'); for i:=1 to n do for j:=1 to n do begin C[i,j]:=(A[i,j]*B[i,j]);end;writeln; for i:=1 to n do begin for j:=1 to n do begin write(C[i,j]:3);end; writeln;end; writeln('Ответ :матрица ВА'); for i:=1 to n do for j:=1 to n do begin D[i,j]:=(B[i,j]*A[i,j]);end; for i:=1 to n do begin for j:=1 to n do begin write(D[i,j]:3);end; writeln;end; end.
Answers & Comments
i, j, n: integer;
begin
Randomize;writeln('Введите размерность n');readln(n);writeln('Матрица А');
for i:=1 to n do begin
for j:=1 to n do begin
A[i,j]:= random(10)+1;write(A[i,j]:3);end;writeln;end;
writeln('Матрица B');
for i:=1 to n do begin
for j:=1 to n do begin
B[i,j]:= random(10)+2;write(B[i,j]:3);end;writeln;end;
writeln('Ответ: матрица AB');
for i:=1 to n do
for j:=1 to n do begin C[i,j]:=(A[i,j]*B[i,j]);end;writeln;
for i:=1 to n do begin
for j:=1 to n do begin
write(C[i,j]:3);end; writeln;end;
writeln('Ответ :матрица ВА');
for i:=1 to n do
for j:=1 to n do begin D[i,j]:=(B[i,j]*A[i,j]);end;
for i:=1 to n do begin
for j:=1 to n do begin
write(D[i,j]:3);end; writeln;end;
end.