Программа:
Pascal:
function summ(n: integer): integer;
begin
n := abs(n);
while n > 0 do begin
result := result + n mod 10;
n := n div 10;
end;
var
n1, n2, n3: integer;
write('n1 = '); readln(n1);
write('n2 = '); readln(n2);
write('n3 = '); readln(n3);
if (summ(n1) > summ(n2)) and (summ(n1) > summ(n3)) then
writeln('Первое число')
else
if (summ(n2) > summ(n1)) and (summ(n2) > summ(n3)) then
write('Второе число')
write('Третье число');
end.
function digitSum(n: integer): integer;
while n > 0 do
Result := Result + n mod 10;
var n1, n2, n3: integer;
n1 := 325;
n2 := 50011;
n3 := 29;
write('Сумма цифр больше у ');
if digitSum(n1) > digitSum(n2) then
if digitSum(n1) > digitSum(n3) then
write('1')
write('3')
write('2');
writeln(' числа');
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
Программа:
Pascal:
function summ(n: integer): integer;
begin
n := abs(n);
while n > 0 do begin
result := result + n mod 10;
n := n div 10;
end;
end;
var
n1, n2, n3: integer;
begin
write('n1 = '); readln(n1);
write('n2 = '); readln(n2);
write('n3 = '); readln(n3);
if (summ(n1) > summ(n2)) and (summ(n1) > summ(n3)) then
writeln('Первое число')
else
if (summ(n2) > summ(n1)) and (summ(n2) > summ(n3)) then
write('Второе число')
else
write('Третье число');
end.
Verified answer
function digitSum(n: integer): integer;
begin
while n > 0 do
begin
Result := Result + n mod 10;
n := n div 10;
end;
end;
var n1, n2, n3: integer;
begin
n1 := 325;
n2 := 50011;
n3 := 29;
write('Сумма цифр больше у ');
if digitSum(n1) > digitSum(n2) then
if digitSum(n1) > digitSum(n3) then
write('1')
else
write('3')
else
write('2');
writeln(' числа');
end.