hoang bai 5 - pascal
program nhanmatran;
uses crt;
var
i,j,k :integer;
n,m,p: integer;
a,b,c: array[1..100,1..100] of integer;
begin
clrscr;
write('nhap vao so hang cua ma tran A'); readln(n);
write('nhap vao so cot cua ma tran A'); readln(m);
write('nhap vao so hang cua ma tran B'); readln(m);
write('nhap vao so cot cua ma tran B'); readln(p);
for i:= 1 to n do
for j:=1 to m do
begin
write('a[',i,',',j,'] := '); readln(a[i,j]);
end;
for i:=1 to m do
for j:=1 to p do
begin
write('b[',i,',',j,'] := '); readln(b[i,j]);
end;
writeln('Ma tran A'); for i:= 1 to n do
begin for j:=1 to m do
write(' ',a[i,j] ,' ');
writeln;
end;
writeln('ma tran B');
for i:=1 to m do
begin
for j:=1 to p do
write(' ',b[i,j] , '');
writeln;
end;
for i:=1 to n do
for j:=1 to p do
for k:=1 to m do
c[i,j] := c[i,j] +a[i,k]* b[k,j];
writeln(' Ma tran A*B' );
for i:=1 to n do
begin
for j:=1 to m do
write(' ', c[i,j],'');
writeln;
end;
readln;
end.
Bạn đang đọc truyện trên: AzTruyen.Top