Pagini recente » Cod sursa (job #2529120) | Cod sursa (job #2419471) | Cod sursa (job #1015135) | Cod sursa (job #262388) | Cod sursa (job #635611)
Cod sursa(job #635611)
Program palm;
var a:array [0..500] of byte;
ch:char;
i,j,max,n:integer;
fi,fo:text;
procedure control();
var x,y,nr:integer;
begin
x:=j-1; y:=i+1; nr:=1;
while (a[x]=a[y]) and (a[x]<=a[x+1]) and (x>=1) and (y<=n) do begin
dec(x); inc(y); nr:=nr+2;
end;
if nr>max then max:=nr;
i:=y-1;
end;
begin
assign(fi,'palm.in');
assign(fo,'palm.out');
reset(fi); rewrite(fo);
while not seekeoln(fi) do begin
inc(n);
read(fi,ch);
a[n]:=ord(ch);
end;
for i:=1 to n do
if (a[i-1]=a[i+1]) and (a[i-1]<=a[i]) then begin
j:=i;
control();
end
else if (a[i]=a[i-1]) then begin
j:=i-1;
control();
end;
write(fo,max);
close(fo);
end.