两个34.7求和为68
#include <stdio.h>
int cost(int tim,int km)
{ double price =2.3; //单价2.3
double start =13; //起步13
double money =0; //总费用
double a = 1; //燃油费1元
if(km < 3)
{
money = start + a;
// printf("收起步费%f\n",money);
}
else if(km>=3)
{ if(tim>23 ||tim<5)
{
money =start +(km-3)*price*1.2 + a;
}
else
{
money =start +(km-3)*price +a;
printf("%f\n",money);
}
}
return money;
}
int main()
{ double money;
money = cost(9,12) + cost(18,12);
printf("打车费用为%f\n",money);
return 0;
}