定义一个函数,此函数的功能是求三个数的最大值,在主函数中输入三个数并调用此函数,最后输出最大值。

如题所述

#include<stdio.h>

int max(int a, int b)
{
    return a > b ? a : b;
}

int main()
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    printf("%d最大\n",max(max(a,b),c) );       // 事实上只需要求两个数最大者就行
    return 0;
}

温馨提示:答案为网友推荐,仅供参考
第1个回答  2014-10-30
#include <stdio.h>
int main()
{
printf("Please input three integer:");
int integer1 = 0, integer2 = 0, integer3 = 0;
scanf("%d %d %d", &integer1, &integer2, &integer3);
int max = integer1;
if (max < integer2)
{
max = integer2;
}
if (max < integer3)
{
max = integer3;
}
printf("the max integer is %d\n", max);
return 0;
}
第2个回答  2014-10-30
int max_num(int a[3]){
int tep;
a[0]>a[1]?tep=a[0]:tep=a[1];
return tep>a[1]?tep:a[2];
}
void main(){
int a[3],max;
scanf("%d",a);
max=max_num(a);
printf("max=%d\n",max);
}本回答被提问者采纳
第3个回答  2014-10-30
function max(double a,double b,double c){
double r =a;
if(r<b)
r=b
if(r<c)
r=c
return r

}
相似回答