Var a,b,c,m1,m2,m3,max:integer;
function sum(n:integer):integer;
var s:integer;
begin
s:=0;
n:=abs(n);
while n>0 do
begin
s:=s+n mod 10;
n:=n div 10;
end;
sum:=s;
end;
begin
write('a, b, c: ');
readln(a,b,c);
m1:=sum(a); m2:=sum(b); m3:=sum(c);
writeln('m1 = ',m1,' m2 = ',m2,' m3 = ',m3);
if m1>m2 then max:=m1 else max:=m2;
if m3>max then max:=m3;
writeln('max = ',max);
end.
Пример:
a, b, c: 45 -3549 138
m1 = 9 m2 = 21 m3 = 12
max = 21