猿问

求帮忙看看哪里错了。。。急,在线等!

北京市出租车打车计费规则如下:
1. 每公里单价计费2.3元
2. 起步价13元(包含3公里)
3. 晚上23点(含)至次日凌晨5点(不含)打车,每公里单价计费加收20%。
4. 每次乘车加收1元钱的燃油附加税。
小明每天上下班都要打车,公司和家的距离为12公里,上午上班时间为9点,下午下班时间为6点。
请编写一个小程序计算小明每天打车的总费用。

#include <stdio.h>
float p(int t,int d)
{
float cost;
if(5>t>=0||24>t>=23)
{
if(d<=3)
cost=13;
else
cost=13+(d-3)*2.3*1.2;
}
else
{
if(d<=3)
cost=13;
else
cost=13+2.3*(d-3);
}
cost+=1;
return cost;
}
int main()
{
float sum=p(9,12)+p(18,12);
printf("小明每天打车的总费用为%f元",sum);
return 0;
}


小益达
浏览 1547回答 1
1回答

luckIsAttitude

你把参数改为double,包括函数中的形参
随时随地看视频慕课网APP
我要回答