Код:
uses Crt;
const n=4;
type matr=array[1..n,1..n] of integer;
function Mon1(aA:matr; ai:integer):boolean;
var j:integer;
begin
Mon1:=true;
j:=2;
While j<=n do
if aA[ai,j]>aA[ai,j-1]
then Inc(j)
else
begin
Mon1:=false; Break;
end;
if Mon1=false
then
begin
Mon1:=true;
j:=n-1;
While j>=1 do
if aA[ai,j]>aA[ai,j+1]
then Dec(j)
else
begin
Mon1:=false; Break;
end;
end;
end;
function Mon2(aA:matr; aj:integer):boolean;
var i:integer;
begin
Mon2:=true;
i:=2;
While i<=n do
if aA[i,aj]>aA[i-1,aj]
then Inc(i)
else
begin
Mon2:=false; Break;
end;
if Mon2=false
then
begin
Mon2:=true;
i:=n-1;
While i>=1 do
if aA[i,aj]>aA[i+1,aj]
then Dec(i)
else
begin
Mon2:=false; Break;
end;
end;
end;
var A:matr;
x,y,S,L:integer;
begin
ClrScr;
Randomize;
for x:=1 to n do
begin
for y:=1 to n do
begin
A[x,y]:=Random(51);
Write(A[x,y]:4);
end;
Writeln;
end;
Writeln;
L:=0;
for x:=1 to n do
if Mon1(A,x) then Inc(L);
S:=0;
for y:=1 to n do
if Mon2(A,y) then Inc(S);
Writeln('Stolbcov =',S);
Writeln('Liniy =',L);
Readkey;
end.