Даны действительные a, b, c, d. Используя функции поиска максимума двух чисел max и минимума двух чисел min, получить: max(a, b)+min(a, b) +min(c,d) ——————––––—––——— . max(a, b, c, d) + min(a,b,c)
Answers & Comments
preceptor
Program Task; Var a, b, c, d: Integer; Function Max(a, b: Integer): Integer; Begin If a > b Then Result := a Else Result := b; End; Function Min(a, b: Integer): Integer; Begin If a < b Then Result := a Else Result := b; End; Begin Write('a = '); ReadLn(a); Write('b = '); ReadLn(b); Write('c = '); ReadLn(c); Write('d = '); ReadLn(d); WriteLn('max(a, b) + min(a, b) + min(c,d) = ', Max(a, b) + Min(a, b) + Min(c,d)); WriteLn('max(a, b, c, d) + min(a, b, c) = ', Max(Max(a, b), Max(c, d)) + Min(Max(a, b), c)); ReadLn; End.
Answers & Comments
Var a, b, c, d: Integer;
Function Max(a, b: Integer): Integer;
Begin
If a > b Then
Result := a
Else
Result := b;
End;
Function Min(a, b: Integer): Integer;
Begin
If a < b Then
Result := a
Else
Result := b;
End;
Begin
Write('a = ');
ReadLn(a);
Write('b = ');
ReadLn(b);
Write('c = ');
ReadLn(c);
Write('d = ');
ReadLn(d);
WriteLn('max(a, b) + min(a, b) + min(c,d) = ', Max(a, b) + Min(a, b) + Min(c,d));
WriteLn('max(a, b, c, d) + min(a, b, c) = ', Max(Max(a, b), Max(c, d)) + Min(Max(a, b), c));
ReadLn;
End.
действительные a, b, c, d. Используя функции