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

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

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

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

Решение 1

var a,b,c : integer;
begin
  writeln('vvedite chislo a-');
  readln(a);
  writeln('vvedite chislo b-');
  readln(b);
  writeln('vvedite chislo c-');
  readln(c);
  if ((a>b) and (a>c)) then
     writeln('max-', a)
  else if ((b>a) and (b>c)) then
     writeln('max-', b)
  else
     writeln('max-', c);
  readln();
end.        

Решение 2

var a,b,c : integer;

begin
  writeln('vvedite celie chisla a b c ');
  read(a,b,c);
  if (a>b) then
     begin
     if (a>c) then
        writeln('max-',a)
     else
        writeln('max-',c)
     end
        else if (b>c) then
           writeln('max=',b)
        else
           writeln('max-',c);
  readln();
end.                     

Решение 3

var a,b,c,d,max1,max2,max3:integer;
begin
  writeln('vvedite chisla A B C D ');
  readln(a,b,c,d);
  if (a>b) then
     max1:=a
  else
     max1:=b;
     if (max1>c) then
        max2:=max1
     else
        max2:=c;
        if (max2>d) then
           max3:=max2
        else
           max3:=d;
        writeln('max-',max3);
  readln();
end.                    
vedro-compota's picture

var a,b,c : integer;
 
begin
  writeln('vvedite celie chisla a b c ');
  read(a,b,c);
  if (a>b) then
     begin
     if (a>c) then
        writeln('max-',a)
     else
        writeln('max-',c)
     end
        else if (b>c) then
           writeln('max=',b)
        else
           writeln('max-',c);
  readln();
end.       

-- проверить для равных чисел + форматирование

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

исправил

var a,b,c : integer;

begin
  writeln('vvedite celie chisla a b c ');
  read(a,b,c);
  if (a>b) then
     begin
     if (a>c) then
        writeln('max-',a)
     else
        writeln('max-',c)
     end
  else if (b>c) then
        writeln('max=',b)
      else
        writeln('max-',c);
  readln();
end. 
vedro-compota's picture

засчитано

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