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.
program s1;
uses
SysUtils;
var
s, t: string;
i: Integer;
c: string;
begin
Write ('Введите строку: ');
ReadLn (s);
t := '';
for i := 1 to Length (s) do begin
if s [i] in ['a'..'z'] then
c := IntToStr (Ord (s [i]) - Ord ('a') + 1)
else if s [i] in ['A'..'Z'] then
c := IntToStr (Ord (s [i]) - Ord ('A') + 1)
else if s [i] = ' ' then
c := '0'
else
c := s [i];
t := t + c + ' ';
end;
WriteLn (t);
ReadLn
end.
program s2;
uses
SysUtils;
var
s, t: string;
i: Integer;
c: string;
begin
Write ('Введите строку: ');
ReadLn (s);
t := '';
for i := 1 to Length (s) do begin
if not (s [i] in ['e', 'y', 'u', 'i', 'o', 'a', 'E', 'Y', 'U', 'I', 'O', 'A']) then
c := s [i]
else
c := '';
t := t + c;
end;
WriteLn (t);
ReadLn
end.