Задача 8 Урок 9
Primary tabs
Пользователь вводит три числа, найдите из них максимальное.
Решите тремя способами:
1. С использованием логической операции and.
var a, b, c: integer;
begin
readln(a,b,c);
if (a>b) and (a>c) then
writeln(a)
else if (c>b) and (c>a) then
writeln(c)
else
writeln(b);
readln();
end. 2.С вложенными блоками (без and, все опtраторы if должны быть в полной форме).
var a, b, c: integer;
begin
readln(a,b,c);
if (a>b) then
if(a>c) then
writeln(a)
else
writeln(c)
else
if (b>c) then
writeln(b)
else
writeln(c);
readln();
end.
3.Без вложенных блоков (без and) -- запомнив максимум из первых двух чисел в специальной переменной.
var a, b, c, d: integer;
begin
readln(a,b,c);
if (a>b) then
d:=a
else
d:=b;
if (c>d) then
writeln(c)
else
writeln(d);
readln();
end. - Log in to post comments
- 420 reads