program media; const NumMaxLin=101; NumMaxCol=51; type indLinhas=0..NumMaxLin; indColunas=0..NumMaxCol; UmaMatriz=array[indLinhas,indColunas] of Real; var m, n, i, j, k : Integer; a : UmaMatriz; function MedAritViz (var a:UmaMatriz; m,n,i,j:Integer):Real; {A matriz a tem uma moldura prenchida com zeros} var numViz:2..4; begin numViz:=2; if (i > 1) and (i < m) then numViz:=numViz+1; if (j > 1) and (j < n) then numViz:=numViz+1; MedAritViz:= (a[i,j-1] + a[i,j+1] + a[i-1,j] + a[i+1,j])/numViz end; procedure MatrizMedAritViz(a:UmaMatriz; m,n:Integer; var b:UmaMatriz); var i,j :Integer; begin for i:=1 to m do for j:=1 to n do b[i,j]:=MedAritViz(a,m,n,i,j) end; begin readLn(m); readLn(n); for i:=1 to m do begin for j:=1 to n do read(a[i,j]); readLn end; <faz moldura na matriz> readLn(k); for i:=1 to k do MatrizMedAritViz(a,m,n,a) end.