#include <stdio.h>
#define PAY 2.3 //每公里2.3元
double SumPay(int times,double distance)
{
if(distance<=3)
return 13+1; //3公里以内13元起步价
else
{
if(times>=23||times<=5)
return (distance-3)*(PAY+2)+13+1; //晚上23点至次日凌晨5点
else (times>5||times<23)
return (distance-3)*PAY+13+1; //白天正常时间
}
}
int main()
{
int go_to_work=9,go_off_work=18; //上下班时间
double distance=12;// 打车距离
double allpay=0; //每天总费用
allpay+=SumPay(go_to_work,distance);
allpay+=SumPay(go_off_work,distance);
printf("小明每天打车的总费用是:%.2lf",allpay);
return 0;
}
hello.c: In function 'SumPay': hello.c:12:9: error: expected ';' before 'return' return (distance-3)*PAY+13+1; //正常时间 ^~~~~~
else (time>5||times<23) ,括号里的内容,不要吧