请大佬看下输出结果为什么是69.400002,是不是把什么定义搞混了,谢谢
#include <stdio.h>
float carmoney(int t, int n, int l)
//t: 时间, n: 乘车次数, l: 距离
{
float sum = 0;
if(l<=3)
{
sum = 13 * n + n * 1;
}
else
{
if(t>=23||t<5)
{
sum = (13 + (l - 3) * 2.3 * 1.2 + 1) * n;
}
else
{
sum = (13 + (l - 3) * 2.3 + 1) * n;
}
}
return sum;
}
int main()
{
float daymoney;
daymoney = carmoney(18, 1, 12) + carmoney(9, 1, 12);
printf("小明每天打车总费用:%f\n", daymoney);
return 0;
}