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

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


У вас есть три числа (три переменные) найдите их медиану.

 var
   a,b,c,max,min,mediana:integer;
begin
  writeln('Vvedite ryad chisel a,b,c: ');
  readln(a,b,c);
  if (a > b) and (a > c) then
  max:=a
  else if (b > a) and (b > c) then
  max:=b
  else if (c > a) and (c > b) then
  max:=c;

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

  if  (a = min) and (b = max) then
  mediana:=c
  else if (a = max) and (b = min) then
  mediana:=c
  else if (b = min) and (c = max) then
  mediana:=a
  else if (b = max) and (c = min) then
  mediana:=a
  else if (c = max) and (a = min) then
  mediana:=b
  else if (c = min) and (a = max) then
  mediana:=b;
  writeln('Mediana ravna: ',mediana);
  readln();
end.   
vedro-compota's picture

форматирование

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

Исправлено.

var
   a,b,c,max,min,mediana:integer;
begin
  writeln('Vvedite ryad chisel a,b,c: ');
  readln(a,b,c);
  if (a > b) and (a > c) then
   max:=a
  else if (b > a) and (b > c) then
   max:=b
   else if (c > a) and (c > b) then
    max:=c;

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

  if  (a = min) and (b = max) then
   mediana:=c
  else if (a = max) and (b = min) then
   mediana:=c
   else if (b = min) and (c = max) then
    mediana:=a
    else if (b = max) and (c = min) then
     mediana:=a
     else if (c = max) and (a = min) then
      mediana:=b
      else if (c = min) and (a = max) then
       mediana:=b;
       writeln('Mediana ravna: ',mediana);
  readln();
end.