Задача 10 Урок 11
Primary tabs
Пользователь вводит целые числа в цикле (разные: четные, нечетные, положительные, отрицательные в любом порядке и количестве). Сохраните в переменные первые три отрицательных нечетных числа, сложите их, выведите сумму на экран и завершите цикл.
var a,b,c,d,i: integer; begin i:=1; while i<=3 do begin writeln('vvedite celoe chislo '); readln(d); if (d<0) and (d mod 2 =-1) then begin if i=1 then a:=d; if i=2 then b:=d; if i=3 then c:=d; i:=i+1; end; if i>3 then writeln('end :',a, '+', b, '+', c , '=', a+b+c ); end; readln(); end.
Консоль:
vvedite celoe chislo 2 vvedite celoe chislo 3 vvedite celoe chislo -3 vvedite celoe chislo -5 vvedite celoe chislo 5 vvedite celoe chislo -3 end :-3+-5+-3=-11
- Log in to post comments
- 291 reads