同學們幫忙看一下,哪錯了啊
#include <stdio.h>
int cost(int distance,int time)
{
? ? double price = 2.3;
? ? double cost;
? ? if(distance<=3){
? ? ? ? cost = 13+1;
? ? }else if(time<=23 && time>5){
? ? ? ? cost = (distance-3)*price+1+13;
? ? }else{
? ? ? ? cost = (distance-3)*(price*1.2)+1+13;
? ? }
}
int main()
{?
? ? double allcost = cost(12,9)+cost(12,18);
? ? printf("小明每天打車是%f塊錢",allcost);
? ??
? ??
? ??
? ? return 0;
}
2019-05-20
2019-05-13
#include <stdio.h>
int cost(int distance,int time)
{
? ? double price = 2.3;
? ? double costs;
? ? if(distance<=3){
? ? ? ? costs = 14;
? ? }else if(time<=23 || time>=5){
? ? ? ? costs = (distance-3)*price+1+13;
? ? ? ? printf("白天車費為:%f\n",costs);
? ? }else{
? ? ? ? costs = (distance-3)*(price*1.2)+1+13;
? ? ? ? printf("夜間車費為:%f\n",costs);
? ? }
}
int main()
{?
? ? double allcost = cost(12,9)+cost(12,18);
? ? printf("小明每天打車是%f塊錢",allcost);
? ??
? ? return 0;
}