如何在C语言编程中求取三个数中的最大值

如题所述

第1个回答  2022-11-09

编写一个C程序,运行时输入a,b,c三个值,输出其中值最大者的步骤:

1、首先输入三个数,求三个数中的最大值

#include<stdio.h>

int main(){    int max(int x,int y,int z);    int a,b,c,m;    scanf("%d,%d,%d",&a,&b,&c);    m=max(a,b,c);    printf("the max number is %d\n",m);    return 0;

}

2、然后输入

int max(int x,int y,int z){    int max2(int a,int b);    int temp,result;    temp=max2(x,y);    result=max2(temp,z);

return(result);

}

3、最后输入

int max2(int a,int b){    int q;    if(a>b)q=a;    else q=b;    return(q);}即可。

相似回答