Урок 9 Задача 8

Урок 9 Задача 8

Пользователь вводит три числа, найдите из них максимальное.
Решите тремя способами:

1. С использованием логической операции and.
2. С вложенными блоками (без and, все операторы if должны быть в полной форме).

3. Без вложенных блоков (без and) -- запомнив максимум из первых двух чисел в специальной переменной.

Program u9z8_1;
var a,b,c:integer;

begin
  writeln('vvedite 3 chisla');
  readln(a,b,c);
  if (a>b) and (a>c)  then
    writeln('max=', a) else
  if (b>c) then
    writeln('max=', b) else
    writeln('max=', c);
  readln();
end.     
Program u9z8_2;
var a,b,c:integer;

begin
  writeln('vvedite 3 chisla');
  readln(a,b,c);
  if (a > b) then
    if (a > c) then
      writeln('max=', a)
    else
      writeln('max=', c)
  else
    if (b > c )then
      writeln('max=', b)
    else
       writeln(c);

  readln();
end.   
Program u9z8_3;
var a,b,c, max:integer;


begin
  writeln('vvedite 3 chisla');
  readln(a,b,c);
  if (a > b) then
      max:=a
    else
      max:=b;

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

       writeln('max=', max);

  readln();
end.   
vedro-compota's picture

Есть вопросы к 3-ему способу решения

 if (a > c) then
    else

-- ветка then не должна быть пустой

_____________
матфак вгу и остальная классика =)