Это всё деревья)). Просто де
===== PascalABC.NET =====
begin
var (k, kmax, s) := (1, 0, 1);
var a := ReadInteger;
if a = 0 then
begin
Print(1);
exit
end;
foreach var b in ReadSeqIntegerWhile(p -> p <> 0) do
begin
var sgn := Sign(b - a);
a := b;
if sgn = s then
k += 1
else
begin
if k > kmax then
kmax := k;
(k, s) := (2, sgn)
end
end;
if k > kmax then
kmax := k;
Print(kmax)
end.
Const e=0.001;
var a1,a2:real;n:integer;
begin
a1:=0.5;
a2:=sin(a1)/cos(a1)/2;
n:=2;
writeln(n,a2:7:4);
while abs(a2-a1)>=e do
begin
a1:=a2;
a2:=sin(a1)/cos(a1)/2;
n:=n+1;
writeln(n,a2:7:4);
end;
writeln('n = ',n);
end.
Результат:
<span>2 0.2732
3 0.1401
4 0.0705
5 0.0353
6 0.0177
7 0.0088
8 0.0044
9 0.0022
10 0.0011
11 0.0006
n = 11</span>