求3个数最大值和最小值的差

求3个数最大值和最小值的差

代码块

int max(int a, int b, int c)
{
    int max;
    if (a>b)
        max = a;
    else
        max = b;
    if (c>max)
        max = c;
    return max;
}
int min(int a, int b, int c)
{
    int min;
    if (a<b)
        min = a;
    else
        min = b;
    if (c<min)
        min = c;
    return min;
}
int fnD(int  a, int b, int c)
{
    return max(a, b, c) - min(a, b, c);
}
int main()
{
    printf("different=%d\n", fnD(1, 2,9));
    system("pause");
    return 0;
}

运行结果:

different=2
请按任意键继续…

    原文作者:ROT1573082949
    原文地址: https://blog.csdn.net/ROT1573082949/article/details/78677743
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞