#include <stdio.h>int Charge(int t,int m){ float sum; //打车费 const float p = 2.3; //单价 const float q = 13; //起步价 if(m <= 3) //判断距离m<=3时的2种情况。 { if(5<t || t<23) { sum =q ; sum ++; return sum; } else { sum = q + m*0.2*p; sum ++; return sum; } } if(m >3) //判断距离m>3时的2种情况。 { if(5<t || t<23) { sum =q + p * (m-3); sum ++; return sum; } else { sum = q + p * (m-3) + p * 0.2 * m; sum ++; return sum; } } }int main(){ int x = 9; int y = 6; int z = 12; float am = Charge(x,z); float pm = Charge(y,z); float money = am + pm; printf("小明每天的打车的总费用是:%.2f\n",money); return 0;}
2 回答
- 2 回答
- 0 关注
- 1215 浏览
添加回答
举报
0/150
提交
取消