今天学习了如何根据某城市普通出租车收费标准编写程序进行车费计算
例如
- 起步里程为3公里,起步费10元;
- 超起步里程后10公里内,每公里2元;
- 超过10公里以上的部分加收50%的回空补贴费,即每公里3元;
- 营运过程中,因路阻及乘客要求临时停车的,按每5分钟2元计收(不足5分钟则不收费)。
- 编码如下
- #include <stdio.h>
int main()
{
float x;
int y;
float v;
scanf("%f %d",&x,&y);
if(x<=3)
{
v=10+y/5*2;
printf("%.0f",v);
}
else if(x>3&&x<=10)
{
v=10+(x-3)*2+y/5*2;
printf("%.0f",v);
}
else
{
v=10+14+y/5*2+(x-10)*3;
printf("%.0f",v);
}
return 0;
} - 结果如下:
-
5.1 4
9
--------------------------------
Process exited after 7.381 seconds with return value 0
请按任意键继续. . . -
3.1 6
12
--------------------------------
Process exited after 16.82 seconds with return value 0
请按任意键继续. . .