Program SumAndMul;
Uses Crt;
var a:array[1..10] of real;
i:integer;
sum,mul:longint;
begin
clrscr;
for i:=1 to 10 do
begin
write('Введите -', i,' число:' );
readln(a[i]);
end;
sum:=0;mul:=1;
for i:=1 to 10 do
begin
if (a[i]>0) then sum:=sum+a[i];
if (a[i]<0 ) then mul:=mul*a[i];
end;
writeln('Сумма положительных элементов: ',sum);
writeln('Произведение отрицательных элементов: ',mul);
readkey;
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.
program ch;
uses
crt;
var
k, cp, no: integer;
begin
k := 1;
cp := 0;
no := 0;
while k <> 0 do
begin
readln(k);
if ((k < 0) and (k mod 2 <> 0)) then
no := no + 1 ;
if ((k > 0) and (k mod 2 = 0)) then
cp := cp + 1 ;
end;
if no > cp then
writeln('Больше нечетных отрицательных') ;
if no < cp then
writeln('Больше четных положительных') ;
if no = cp then
writeln('Количество четных положительных равно количеству нечетных отрицательных') ;
readln;
end.