var
i, si, N, ss: Integer;
s: string;
begin
Write ('Введите N: ');
ReadLn (N);
s := IntToStr (N);
ss := 0;
for i := 1 to Length (s) do begin
si := StrToInt (s [i]);
if si mod 4 <> 0 then
ss := ss + si;
end;
Writeln ('Сумма цифр = ' + IntToStr (ss));
end.
// второй вариант решения
var
si, N, ss: Integer;
begin
Write ('Введите N: ');
ReadLn (N);
ss := 0;
while N > 0 do begin
si := N mod 10;
N := N div 10;
if si mod 4 <> 0 then
ss := ss + si;
end;
Writeln ('Сумма цифр = ' + IntToStr (ss));
end.
var
i, si, N, ss: Integer;
s: string;
begin
Write ('Введите N: ');
ReadLn (N);
s := IntToStr (N);
ss := 0;
for i := 1 to Length (s) do begin
si := StrToInt (s [i]);
if si mod 4 <> 0 then
ss := ss + si;
end;
Writeln ('Сумма цифр = ' + IntToStr (ss));
end.
// второй вариант решения
var
si, N, ss: Integer;
begin
Write ('Введите N: ');
ReadLn (N);
ss := 0;
while N > 0 do begin
si := N mod 10;
N := N div 10;
if si mod 4 <> 0 then
ss := ss + si;
end;
Writeln ('Сумма цифр = ' + IntToStr (ss));
end.
n : integer;
max: byte;
begin
write ('Введите число: ');
readln (n);
n:=abs (n);
while n>0 do
begin
if (n mod 10)>max then max:=n mod 10;
n:=n div 10;
end;
write ('Макс. цифра - ', max);
end.