Шеншин
4 год назад
Даны 3 различных числа. Определить, какое из них (первое, второе или третье) является средним. По программированию Паскаля. Пожалуйста посчитайте пожалуйста!
ОТВЕТЫ
Agata
Oct 24, 2020
var
a, b, c: real;
function IsBetween(x, a, b: real): boolean;
var
t: real;
begin
if a < b then
begin
t := a;
a := b;
b := t;
end;
IsBetween := (a >= b) and (a >= x) and (x >= b);
end;
begin
Readln(a, b, c); // не вводить одинаковых!
Write('Среднее число №');
if IsBetween(a, b, c) then writeln(1);
if IsBetween(b, a, c) then writeln(2);
if IsBetween(c, b, a) then writeln(3);
end.
a, b, c: real;
function IsBetween(x, a, b: real): boolean;
var
t: real;
begin
if a < b then
begin
t := a;
a := b;
b := t;
end;
IsBetween := (a >= b) and (a >= x) and (x >= b);
end;
begin
Readln(a, b, c); // не вводить одинаковых!
Write('Среднее число №');
if IsBetween(a, b, c) then writeln(1);
if IsBetween(b, a, c) then writeln(2);
if IsBetween(c, b, a) then writeln(3);
end.
571
Смежные вопросы: