Var a,s1,s2,i:integer;
begin
a:=random(4901)+100;
writeln('a = ',a);
s1:=0; s2:=0;
for i:=1 to 4 do
begin
if a mod 2 = 0
then s1:=s1+a mod 10 else s2:=s2+a mod 10;
a:=a div 10;
end;
writeln('Сумма чётных цифр = ',s1,' Сумма нечётных цифр = ',s2);
end.
Пример:
<span>a = 4683
Сумма чётных цифр = 18 Сумма нечётных цифр = 3</span>
Program raketa;
uses graph;
var gd,gm:integer;
begin
detectgraph (gd,gm);
initgraph (gd,gm,'C:\tp7 ');
line (300,60,240,120);
line (240,120,240,360);
line (360,120,360,360);
line (240,360,360,360);
line (300,60,360,120);
line (240,210,210,240);
line (210,240,240,240);
line (360,210,390,240);
line (390,240,360,240);
circle (300,150,15);
circle (300,210,15);
circle (300,270,15);
Bar (270,300,240,360);
line (240,360,180,450);
line (180,450,420,450);
line (420,450,360,360);
line (330,450,330,370);
line (300,450,300,365);
line (270,450,270,370);
line (240,330,180,330);
line (180,330,90,450);
line (172,330,80,445);
line (300,60,300,30);
readln
end<span>.</span>