5.13课后训练
→_→→_→
#include <stdio.h>
int my_charge(float time,double km);
int main()
{
double cost=0;
cost=cost+my_charge(9,12);
cost=cost+my_charge(18,12);
printf("总费用是:%f",cost);
return 0;
}
int my_charge(float time,double km)
{
double danjia=2.3,qibu=13,cost=0;
if(km<=3)
{
cost=14;
}
else
{
cost=13+(km-3)*2.3+1;
}
if ((time>=23&&time<=24)||(time>=0&&time<=6))
{
cost=cost*1.2;
}
return cost;
}
举报