Регистрация
Войти
Стать экспертом Правила
Информатика

Дано 4 числа. Найти наибольшие и наименьшее число с помощью if/else.​

ОТВЕТЫ

var a, b, c, d, min, max: integer;

begin

 // Min

 readln(a, b, c, d);

 if (a <= b) and (a <= c) and (a <= d) then min := a

 else if (b <= a) and (b <= c) and (b <= d) then min := b

 else if (c <= a) and (c <= b) and (c <= d) then min := c

 else if (d <= a) and (d <= b) and (d <= c) then min := d;

 // Max

 if (a >= b) and (a >= c) and (a >= d) then max := a

 else if (b >= a) and (b >= c) and (b >= d) then max := b

 else if (c >= a) and (c >= b) and (c >= d) then max := c

 else if (d >= a) and (d >= b) and (d >= c) then max := d;

 writeln('Min: ', min);

 writeln('Max: ', max);

end.

285
Контакты
Реклама на сайте
Спрошу
О проекте
Новым пользователям
Новым экспертам