Код
uses
crt;
var
f:text;
tmp:string;
i,n,summ,max:integer;
begin
clrscr;
assign(f,'in.txt');
reset(f);
max:=0;
summ:=0;
repeat
readln(f,tmp);
for i:=1 to length(tmp) do begin
if tmp[i] in ['1'..'9'] then begin
n:=ord(tmp[i])-ord('0');
summ:=summ+n;
if n>max then max:=n;
end;
end;
until eof(f);
close(f);
writeln('Summa=',summ);
writeln('Max=',max);
readln;
end.