Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program tinhtong_matran;
- uses crt;
- type
- mang=array[1..10,1..10] of integer;
- var
- a,b,p:mang;
- i,j,h,c,ha,ca,hb,cb:integer;
- procedure nhap(var m:mang; ch:char; var h,c:integer);
- begin
- writeln('Nhap ma tran ',ch);
- write('Nhap hang: ');
- readln(h);
- write('Nhap cot : ');
- readln(c);
- for i:=1 to h do
- for j:=1 to c do
- begin
- write(ch,'[',i,',',j,']=');
- readln(m[i,j]);
- end;
- end;
- procedure xuat(var m:mang; ch:char; var h,c:integer);
- begin
- writeln('In ma tran ' , ch);
- for i:=1 to h do
- begin
- for j:=1 to c do write (m[i,j]:3);
- writeln;
- end;
- end;
- procedure tinhtong(var m,n,t:mang; h,c:integer);
- begin
- for i:=1 to h do
- for j:=1 to c do
- t[i,j]:= m[i,j]+n[i,j];
- end;
- begin
- clrscr;
- nhap(a,'a',ha,ca);
- nhap(b,'b',hb,cb);
- xuat(a,'a',ha,ca);
- xuat(b,'b',hb,cb);
- if (ha=hb) and (ca=cb) then
- begin
- tinhtong(a,b,p,ha,ca);
- xuat(p,'p',ha,ca);
- end
- else
- writeln('Khong tinh tong duoc a,b');
- readln;
- end.
Advertisement
Add Comment
Please, Sign In to add comment