为了账号安全,请及时绑定邮箱和手机立即绑定

大佬指点一下,有其他更好的思路吗?

#include <stdio.h>

float sale(float km, int s, int x);


int main() {

printf("小明每天打车的总费用:%.2f", sale(12, 9, 18));

return 0;

}


float sale(float km, int s, int x) {

if (km < 3) {

if (s > 5 & x < 23)

return 14 * 2;

else if (s > 5 & x > 23 || s < 5 & x < 23)

return 14 + 14 * 1.2;

else

return 14 * 2 * 1.2;

} else {

if (s > 5 & x < 23)

return (14 + (km - 3) * 2.3) * 2;

else if (s > 5 & x > 23 || s < 5 & x < 23)

return (14 + (km - 3) * 2.3) * 2.2;

else

return (14 + (km - 3) * 2.3) * 2.4;

}

}


正在回答

代码语言

举报

0/150
提交
取消

大佬指点一下,有其他更好的思路吗?

我要回答 关注问题
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号