#include <stdio.h>int maxfun(int a,int b) //直接用三目运算符? :实现.
{
return a>b?a:b;
}
void main()
{
int a,b,c,max;
scanf("%d%d%d",&a,&b,&c); //从键盘输入三个数.
max=maxfun(a,maxfun(b,c)); //调用函数. 返回三个数中的最大数.
printf("max=%d\n",max); //输出最大数
}****************************************************************************************用if语句实现:#include <stdio.h>int maxfun(int a,int b,int c) //if 结构. 函数返回三个数中的最大数.
{
int max=a;
if(max<b) max=b;
if(max<c) max=c;
return max;
}
void main()
{
int a,b,c,max;
scanf("%d%d%d",&a,&b,&c); //从键盘输入三个数.
max=maxfun(a,b,c); //调用函数. 返回三个数中的最大数.
printf("max=%d\n",max); //输出最大数.
嘿嘿......手快有..手慢就没咯...
温馨提示:答案为网友推荐,仅供参考