Var A,B,n,M:integer; Begin Write('A = ');ReadLn(A); While A<>0 do Begin if (A mod 10) mod 2 = 0 then Begin M:=1; For n:= 0 to n do M:=M*10; B:=(A mod 10)*M+B; n:=n+1; End; A:=A div 10; End; WriteLn(B div 10); End.
//PascalABC.Net 3.2 begin var s:=readstring('Введите число: '); var i:=1; var m:=['2', '4', '6', '8', '0']; while i<=length(s) do begin if s[i] in m then delete(s, i, 1); inc (i); end; write (s); end.
Begin
Write('A = ');ReadLn(A);
While A<>0 do
Begin
if (A mod 10) mod 2 = 0 then
Begin
M:=1;
For n:= 0 to n do
M:=M*10;
B:=(A mod 10)*M+B;
n:=n+1;
End;
A:=A div 10;
End;
WriteLn(B div 10);
End.
Пример:
A = 123456789
2468
begin
var s:=readstring('Введите число: ');
var i:=1; var m:=['2', '4', '6', '8', '0'];
while i<=length(s) do
begin
if s[i] in m then delete(s, i, 1);
inc (i);
end;
write (s);
end.