為什么這樣算不對啊?
#include?<stdio.h>double?cost(int?x,int?time){?//x為路程??
double?y;?//y為費用????
if(x?<=?3?&&?0?<=?time?<=?24){????????
y?=?13?+?1;????????
}else?if(x?>?3){????????????
if(time?<?5?||?time?>?23)?{???????????????
y?=?13?+?1?+?2.3*1.2*(y?-?3);????????????
}????????????
else?if(time?>=?5?||?time?<=?23){???????????????
y?=?13?+?1?+?2.3*(y?-?3);????????????
}????????
}
}????
int?main(){????
printf("打車總費用為:%f",cost(12,9)+cost(12,18));????
return?0;}
2021-08-20
我知道了,x-3,寫成y-3了