begin
readln(n);
k:=n mod 10;
while n>0 do begin
n:=n div 10;
if k<(n mod 10) then k:=n mod 10;
if k=9 then break;
end;
writeln(k);
end.
begin
m:=0;
while n>0 do
begin
if n mod 10 > m then m:=n mod 10;
n:=n div 10;
end;
end;
var a,k:integer;
begin
write('a = ');
readln(a);
max(a,k);
writeln('max = ',k);
end.
Пример:
a = 2583
max = 8
begin
readln(n);
k:=n mod 10;
while n>0 do begin
n:=n div 10;
if k<(n mod 10) then k:=n mod 10;
if k=9 then break;
end;
writeln(k);
end.