Function min(a, b: real): real;
begin
if ((a = b) or (a < b)) then result := a
else result := b;
end;
function max(a, b: real): real;
begin
if ((a = b) or (a > b)) then result := a
else result := b;
end;
procedure prog(a, b, c, d: real);
begin
writeln(max(a, b)+min(a, b) + min(c,d));
end;
var a, b, c, d: real;
begin
readln(a, b, c, d);
prog(a, b, c, d);
end.
Вот, тут тебе и процедура, и функции:)