题解 | #小乐乐计算函数#

小乐乐计算函数

https://www.nowcoder.com/practice/89238e99c36e450786ccf3a9e7481b7b

#include <stdio.h>

int max(int x, int y, int z)//最大函数
{
    int arr[3] = {0};
    arr[0] = x;
    arr[1] = y;
    arr[2] = z;
    int i;
    int max = arr[0];
    for (i = 0; i < 3; i++)
    {
        if (arr[i] > max)
        {
            max = arr[i];
        }
    }
    return max;
}

int main() {
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);//输入

    int son = max(a+b, b, c);//调用函数
    int m1 = max(a, b+c, c);
    int m2 = max(a, b, b+c);

    int m = m1 + m2;
    float answer = (float)son / m;//公式结果
    printf("%.2f\n", answer);//打印

    return 0;
}

C语言基础 文章被收录于专栏

里面较为详细的介绍了c语言的相关用法和有关题目。

全部评论

相关推荐

MinJerous:虽然我一直说 计算机不怎么卡学历 但是至少得一本
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务