慕先生2341358
2019-11-03 22:12
#include <stdio.h>
int gongli;
double qian;
int shijian;
if(shijian>23||shijian<5)
{
if(gongli<=3)
{
qian=14;
return qian;
}
else
{
qian == 14+2.76*(gongli-3);
return qian;
}
}
else
{
if(gongli<=3)
return qian;
}
else
{
qian == 14+2.3*(gongli-3);
return qian;
}
}
}
int main()
{int gongli ==12;
int shijian == 9;
printf("每天打车的总费用%lf",qian);
return 0;
}
按照你的思路改了下你的代码 你自己对比看下吧。
#include <stdio.h> int gongli = 12;int shijian = 9;float qian(){ if(shijian > 23 || shijian < 5) { if(gongli <= 3) { return 13; } else { return 13 + 2.3 * ( gongli - 3 ) * 1.2; } } else { if(gongli <= 3){ return 13; } else { return 13 + 2.3 * (gongli-3); } }} int main(){ printf("每天打车的总费用%lf",qian()); return 0;}
C语言入门
926209 学习 · 20797 问题
相似问题