program raf105;
var
a,i,j,s: integer;
f,st: string;
inA,inB: boolean;
begin
readln(a);
readln(f);
i:=1;
while i < length(f)-1 do
begin
st:= f[i] + f[i+1];
inA:= False;
inB:= False;
for j:=1 to length(st)-1 do
begin
if st[j] = 'a' then inA:= True;
if st[j] = 'b' then inB:= True;
end;
if (not inA) or (not inB) then
if st = 'bb' then
f[i+1]:= 'a'
else
f[i+1]:= 'b';
s:= s+1;
i+= 2;
end;
writeln(s);
for i:=1 to length(f)-1 do
write(f[i],' ');
end.
<h3>PascalABC</h3>
Var n,k:integer;
begin
writeln('n=',n);readln(n);
k:=0;
while n<>0 do
begin
if n mod 10 mod 2 =1 then k:=k+1;
n:=n div 10;
end;
writeln('k=',k);
<span>end.</span>
Ответ:
def process_input(number):
numlist = list(number)
first_part = int(numlist[0])+int(numlist[1])
center_part = int(numlist[1])+int(numlist[2])
last_part = int(numlist[2])+int(numlist[3])
return first_part*center_part*last_part
def main():
input_number = input()
assert len(input_number) == 4
result = process_input(input_number)
print(result)
if __name__ == '__main__':
main()
Объяснение:
P.S Для восстановления нормального состояния программы предоставлен её скриншот. Сайт напрочь ломает Python-код.
Ответ:
program CountNum;
uses
SysUtils;
var
n, i, c: Integer;
s: string;
begin
Write ('Введите N: ');
ReadLn (n);
s := IntToStr (n);
c := 0;
for i := 1 to Length (s) do begin
if StrToInt (s [i]) mod 2 = 0 then
Inc (c);
end;
WriteLn ('Количество четных цифр = ', c);
ReadLn;
end.