Дана матрица размером m*n. надо вывести номер монотонного возрастающего столбца если он существует а если нет вывести что их нет — Pascal(Паскаль)

uses crt;
const nmax=20;
var a:array[1..nmax,1..nmax] of integer;
b:array[1..nmax] of integer;
m,n,i,j,ks,f:byte;
begin
clrscr;
repeat
write('kolichestvo strok do ',nmax,' n=');
readln(n);
until n in [1..nmax];
repeat
write('kolichestvo stolbcov do ',nmax,' m=');
readln(m);
until m in [1..nmax];
writeln('vvedite elementy matricy po stolbcam:');
for j:=1 to m do
begin
writeln('stolbec ',j);
for i:=1 to n do
begin
write('a[',i,',',j,']=');
readln(a[i,j]);
end;
end;
clrscr;
writeln('ishodnaja matrica:');
for i:=1 to n do
begin
for j:=1 to m do
write(a[i,j]:4);
writeln;
end;
writeln;
ks:=0;{kolichestvo stolbcov, yporadochenyu strgo po vozrastaniy, tipa 1 8 25 40}
for j:=1 to m do
begin
f:=0;{flag fiksacii aryshenija posledov}
for i:=2 to n do
if a[i,j]<a[i-1,j] then{esli naryshna posled}
begin
f:=1;{menjaet znachenie flaga}
break;{vyhodim iz cikla}
end;
if f=0 then
begin
ks:=ks+1;{esli flag ne smenilsja, schitaem stolbec}
b[ks]:=j;
end;
end;
if ks>0 then
begin
writeln('kolichestvo stolbcov yporadochenyh strogo po vozrastaniyu=',ks);
writeln('nomer');
for i:=1 to ks do
write(b[i]:4);
end
else writeln('stolbcov yporadochenyh strogo po vozrastaniyu net');
readln
end.

Leave a Comment

31 + = 40