Задача 8 Урок 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 );
end;
readln();
end.Консоль:
vvedite celoe chislo 2 vvedite celoe chislo -2 vvedite celoe chislo 3 vvedite celoe chislo -3 vvedite celoe chislo -5 vvedite celoe chislo 8 vvedite celoe chislo -9 end :-3-5-9
- Log in to post comments
- 803 reads