题解 | #小乐乐计算函数#
小乐乐计算函数
https://www.nowcoder.com/practice/89238e99c36e450786ccf3a9e7481b7b
#include <stdio.h>
int max3(int a,int b,int c)
{
int max=a;//直接将定义最大值变量为a,然后与另外两个数进行比较
if(max<b)
max=b;
if(max<c)
max=c;
return max;
}
int main()
{
int a,b,c;
scanf("%d %d %d",&a,&b,&c);
int x=max3(a+b,b,c);
int y=max3(a,b+c,c);
int z=max3(a,b,b+c);
float m=(float)x/(y+z);//因为当初定义a,b,c的时候是以整型类型定义的,所以在这里要进行强制类型转换,如果不想这么写,那么就在开头将这三个值定义为浮点型
printf("%.2f",m);
return 0;
}