unit ma tran
Unit MAT;
Interface
var a,b,c:array[1..20,1..20] of real;
i,n,m,j,k,l,t:integer;
Procedure taoMAT;
Procedure NhanMT;
Implementation
Procedure taoMAT;
begin
write('Nhap so hang cua mat a: ');readln(n);
write('Nhap so cot cua mat a: ');readln(m);
write('Nhap so hang cua mat b: ');readln(l);
write('nhap so cot cua mat b: ');readln(k);
writeln('Nhap cac phan tu cua MAT A: ');
for i:=1 to n do
for j:=1 to m do
begin
write('a[',i,j,']=');
readln(a[i,j]);
end;
writeln('Nhap cac phan tu cua MAT B: ');
for i:=1 to l do
for j:=1 to k do
begin
write('b[',i,j,']=');
readln(b[i,j]);
end;
readln;
end;
Procedure NhanMT;
Begin
writeln('MAT C tinh duoc la: ');
for i:=1 to n do
for j:=1 to k do
if m=l then
Begin
c[i,j]:=0;
for t:=1 to m do
c[i,j]:=c[i,j]+a[i,t]*b[t,j];
end
else write('Khong nhan duoc');
end;
end.
program vd;
uses crt,mat;
begin
clrscr;
taoMAT;
NhanMT;
for i:=1 to n do
begin
for j:=1 to k do
write(c[i,j]:10:2);
writeln;
end;
readln;
end.
Bạn đang đọc truyện trên: Truyen247.Pro