运行成功,但计算结果不对
#include <stdio.h>
int cal(int km, int tm)
{
float start = 13;
float ppk = 2.3;
float price;
if(km<=3)
{
price = (start+1)*2;
printf("打车总费用为%f元。", price);
}
else if(0<=tm<5 || tm>=23)
{
price = (start + ppk*(km-3)*1.2+1)*2;
printf("打车总费用为%f元。", price);
}
else
{
price = (start+ ppk*(km-3) + 1)*2;
printf("打车总费用为%f元。",price);
}
return price;
}
int main()
{
cal(12,9);
return 0;
}
计算结果用了第二种情况,加了20%,但看起来逻辑没错呀?
求大神