题解 | #小乐乐计算函数#
小乐乐计算函数
https://www.nowcoder.com/practice/89238e99c36e450786ccf3a9e7481b7b
#include <stdio.h> double three_max(double x, double y, double z); int main() { double a = 0; double b = 0; double c = 0; scanf("%lf %lf %lf", &a, &b, &c); // 分母 double deno = three_max(a, b + c, c) + three_max(a, b, b + c); // 分子 double mol = three_max(a + b, b, c); printf("%.2f\n", mol / deno); return 0; } double three_max(double x, double y, double z) { // 假设x是最大值 if (x < y) { double tmp = x; x = y; y = tmp; } if (x < z) { double tmp = x; x = z; z = tmp; } return x; }