uses wincrt;

const max_size = 10;

var a,b,c:array[1..max_size] of array[1..max_size] of real;
    ar,ac,br,bc:integer;
    i,j,k:integer;
begin

clrscr;
writeln('This program will multiply two matrices A X B');
writeln;
writeln('Enter the number of rows in Matrix A:    '); readln(ar);
writeln('Enter the number of columns in Matrix A: '); readln(ac);

clrscr;

writeln(ar,'x',ac);

for i := 1 to ar do
  for j := 1 to ac do
    begin
      gotoxy(6,1); writeln('| Enter number for ',i,',',j,':');
      gotoxy((j-1)*(72 div ac)+6,i*2+1);
      readln(a[i][j]);
    end;

br := ac;
clrscr;
writeln('This program will multiply two matrices A X B');
writeln;
writeln('Enter the number of rows in Matrix B:    '); writeln(br);
writeln('Enter the number of columns in Matrix B: '); readln(bc);

clrscr;

writeln(ar,'x',ac);

for i := 1 to br do
  for j := 1 to bc do
    begin
      gotoxy(6,1); writeln('| Enter number for ',i,',',j,':');
      gotoxy((j-1)*(72 div bc)+6,i*2+1);
      readln(b[i][j]);
    end;

{cr := ar;
 cc := bc: }

for i := 1 to ar do
  for j := 1 to bc do
     c[i][j] := 0;

for i := 1 to ar do
  for j := 1 to bc do
    for k := 1 to ac do
    begin
      c[i][j] :=  c[i][j] + a[i][k]*b[k][j];
    end;


clrscr;
writeln(ar,'x',bc);
gotoxy(6,1); writeln('| Matrix C:');

for i := 1 to ar do
  for j := 1 to bc do
    begin
      gotoxy((j-1)*(72 div bc)+6,i*2+1);
      writeln(c[i][j]:3:0);
    end;

end.