c语言程序设计 定义一个函数求两个数的最大值,在住函数中调用该函数求三个数的最大值并输出.

如题所述

参考程序如下:(我自己编写的,可能有不足之处,望见谅)
#include<stdio.h>
int max(int x,int y)
{
int t;
t=x>y? x:y;
return t;
}
void main()
{
int a,b,c,m;
printf("please input three numbers:\n");
scanf("%d,%d,%d",&a,&b,&c);
m=max(max(a,b),c);
printf("the maximum of the three numbers is:%d\n",m);
}
温馨提示:答案为网友推荐,仅供参考
第1个回答  2009-12-07
#include "stdio.h"
#define N 3
int max(int,int);

int main(void)
{
int a[N];

printf("输入数据:");
scanf("%d%d%d",&a[0],&a[1],&a[2]);
printf("max=%d",max(max(a[0],a[1]),a[2]));

return 0;
}
int max(int max,int min)
{
if(min>max) max=min;
return max;
}
第2个回答  2009-12-07
Max(int a ,int b){
if(a>b)return a;
else return b;
}
Main(){
int a,b,c;
int max;
max=Max(a,Max(b,c));
printf(%d,max);
相似回答