求大佬帮我看看哪里的问题
#include <stdio.h>
float dache(int h)
{
float x;
if(h>=5&&h<23)
{
x=13+2.3*9;
}
else
{
x=13+2.3*1.2*9;
}
return x;
}
int main()
{
float a=dache(9);
float b=dache(18);
printf("小明每天打车的总费用为%f元",a+b);
return 0;
}
#include <stdio.h>
float dache(int h)
{
float x;
if(h>=5&&h<23)
{
x=13+2.3*9;
}
else
{
x=13+2.3*1.2*9;
}
return x;
}
int main()
{
float a=dache(9);
float b=dache(18);
printf("小明每天打车的总费用为%f元",a+b);
return 0;
}
2020-04-02
我的是这样做的
#include <stdio.h> float Taxi(int h,int k){ float money; int km; float unit = 2.3; if(h>=23&&h<5){ if(km<=3){ money=13; }else{ money = 13 + (km-3)*unit*1.2 + 1; } }else{ if(km<=3){ money=13; }else{ money = 13 + (km-3)*unit + 1; } } return money; } int main(){ float moneysum; moneysum = Taxi(9,12)+Taxi(18,12); printf("小明每天打车的总费用为:%f",moneysum);//26 }
#include <stdio.h>float taxi(int clock,int miles){ float money; if(miles<=3) { money=14; printf("费用为14\n"); } else { if(clock>=23 || clock<5) { money=13+1+2.3*(miles-3)*1.2; printf("夜间车费为:%f\n",money); } else { money=13+1+2.3*(miles-3); printf("日间车费为:%f\n",money); } } return money; }int main(){ printf("打的总费用:%.1f\n",taxifee(9,12)+taxifee(18,12)); return 0;}
举报