Количество промежутков монотонности нашла. А как вывести сами промежутки (наименьшее и наибольшее число из каждого промежутка)?
Код:
procedure TForm1.Button2Click(Sender: TObject);
var
col,i:integer;
A: array of integer;
bolx,boln:boolean;
begin
for i:=0 to Memo1.Lines.Count-1 do begin
SetLength(A, Memo1.Lines.Count);
A[i]:= StrToInt(Memo1.Lines.strings[i]);
boln:=false;
bolx:=false;
col:=0;
end;
for i:=2 to Memo1.Lines.Count do
begin
if (a[i]< a[i-1])and (not bolx) then begin inc(col);
bolx:=true;
end;
if a[i]>= a[i-1]then bolx:=false;
if (a[i]> a[i-1])and (not boln) then begin inc(col);
boln:=true;
end;
if a[i]<= a[i-1]then boln:=false;
end;
Edit1.Text:=IntToStr(col);
end;
end.