Сумма и произведение матриц. program Summ_Proizv;
{$APPTYPE CONSOLE}
uses SysUtils;
const n = 5;
var a, b, c, summ, p: array[1..n, 1..n] of integer; i, j, st: integer;
begin writeln('Matrics A'); for i:= 1 to n do begin for j:= 1 to n do begin a[i, j]:= Round(Random(10)-5); write(a[i,j]:5); end; writeln; end;
writeln('Matrics B'); for i:= 1 to n do begin for j:= 1 to n do begin b[i, j]:= Round(Random(10)-5); write(b[i,j]:5); end; writeln; end;
writeln('Matrics C'); for i:= 1 to n do begin for j:= 1 to n do begin c[i, j]:= Round(Random(10)-5); write(c[i,j]:5); end; writeln; end; writeln('Matrics A+B'); for i:= 1 to n do begin for j:= 1 to n do begin summ[i,j]:= a[i,j] + b[i,j]; write(summ[i,j]:5); end; writeln; end; writeln('Matrics (A+B) * C'); for i:= 1 to n do begin for j:= 1 to n do begin p[i,j]:= 0; for st:= 1 to n do p[i,j]:= p[i,j] + summ[i,st]* c[st,j]; write(p[i,j]:5); end; writeln; end;
readln;
end.
|