Задача 6 урок 9
Primary tabs
http://fkn.ktu10.com/?q=node/8539
Пользователь вводит три числа, найдите из них максимальное.
Решите тремя способами:
С использованием логической операции and (все опараторы if должны быть в полной форме).
С вложенными блоками (без and).
Без вложенных блоков (без and) -- запомнив максимум из двух в специальной переменной.
program task6_lesson9; var a,b,c:integer; max1,max2, max3:integer; begin writeln('Enter three integers'); readln(a,b,c); if (c>a) and (c>b) then // Вариант 1 writeln('The biggest number is - c: ',c) else if (a>b) and (a>c) then writeln('The biggest number is - a: ',a) else writeln('The biggest number is - c: ',c); if a>b then // Вариант 2 begin if a>c then writeln('The biggest number is - a: ',a) else if c>b then writeln('The biggest number is - c: ',c) end else if b>c then writeln('The biggest number is - b: ',b); // Вариант 3 if (a>b) then max2:=a else max2:=b; if (max2>c) then max3:=max2 else max3:=c; max1:=max3; writeln('The biggest number is - ',max1); readln(); end.
- Log in to post comments
- 412 reads