В процедуре заполните квадратную матрицу третьего порядка с клавиатуры, а в функции проверьте, все ли диагональные элементы равны нулю. Если не все, то в основной программе вычислить сумму диагональных элементов и прибавить это значение к любому недиагональному элементу, а диагональные - обнулить.
const
m=3;
type
ta = array[1..m,1..m] of integer;
var
a: ta;
i,j: integder;
function CheckDiagonalForAllZero(var x: ta): boolean;
var
i: integer;
b: boolean;
begin
b:=true;
i:=1;
while b and (i<=m) and (x[i,i,]=0) do Inc(i);
CheckDiagonalForAllZero:=b
end;
begin
{ filling in the matrix }
WriteLn('Type in the matrx elements:');
for i:=1 to m do for j:=1 to m do begin
Write('a[',i,',',j,'] = ');
ReadLn(a[i,j])
end;
{ print out the matrix }
WriteLn('Now, that we have this matrix:');
for i:=1 to m do begin
for j:=1 to m do WriteLn(a[i,j]:4);
WriteLn
end;