为什么sum加不起来,请教大神!
#include <stdio.h>
int calc_price(float mile, int time)
{
float sum_price;
float per_price = 2.3;
int primary_price = 13;
if(time >= 5 && time < 23)
{
if(mile < 3)
sum_price = primary_price + mile * per_price + 1;
else
sum_price = primary_price + (mile - 3) * per_price + 1;
printf("您在%d点打车,打车费用为%.2f\n", time, sum_price);
}
else
{
if(mile < 3)
sum_price = primary_price + mile * (per_price * 0.2) + 1;
else
sum_price = primary_price + (mile - 3) * (per_price * 0.2) + 1;
printf("您在%d点打车,打车费用为%.2f\n", time, sum_price);
}
return sum_price;
}
int main()
{
printf("打的总费用:%.2f\n",calc_price(12, 9) + calc_price(12, 18));
return 0;
}