求大神教一下怎么改,然而公里和时间反过来答案才对,不知道哪里写错了,谢谢大神!
#include <stdio.h>
float kmprice=2.3;
float price(int km,int n){
float sum;
if(n<5||n>=23){
if(km<=3){
return 14;
}
else{
sum=14+(n-3)*kmprice*1.2;
return sum;
}
}
else{
if(km<=3){
return 14;
}
else{
sum=14+(n-3)*kmprice;
return sum;
}
}
}
int main()
{
int a,b,c;
a=12;
b=9;
c=18;
float allprice=price(a,b)+price(a,c);
printf("一天的打车费用为:%.2f\n",allprice);
return 0;
}