#include <stdio.h>
float cost(int c,int miles)
{
float money;
if (miles<=3)
{
money=14;
}
else
{
if (c>=23||c<5)
{
money=13+(miles-3)*2.3*1.2+1;
}
else
{
money=13+(miles-3)*2.3+1;
}
return money;
}
int main()
{
printf("小明打车费用为:%.2f\n",cost(9,12)+cost(18,12));
return 0;
}
#include <stdio.h>
double dlVal(double dlTime,double dlLen)
{
double dlTmp = 13;
if(dlLen > 3)
{
if (dlTime >=23 || dlTime < 5)
{
dlTmp += 2.3 * (dlLen-3) * 1.2;
}
else
{
dlTmp += 2.3* (dlLen-3) * 1.2;
}
}
return dlTmp;
}
int main()
{
double Val = dlVal(9,12)+dlVal(18,12);
printf("小明打车总费用为:%f 元。", Val);
return 0;
}