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