本题要求根据某城市普通出租车收费标准编写程序进行车费计算。具体标准如下:
输入在一行中给出输入行驶里程(单位为公里,精确到小数点后1位)与等待时间(整数,单位为分钟),其间以空格分隔。
在一行中输出乘客应支付的车费(单位为元),结果四舍五入,保留到元。
2.6 2
10
5.1 4
14
12.5 9
34
#include <stdio.h>
int main() {
float s;
int t;
scanf("%f%d", &s, &t);
if (t <= 5) {
if (s <= 3)
printf("10");
else if (s > 3 && s <= 10)
printf("%d", 2 * (s - 3) + 10);
else if (s > 10)
printf("%d",3 * (s - 10) + 10 + 2 * 10 );
} else if (t > 5) {
if (t % 5 != 0) {
if (s > 3 && s <= 10)
printf("%d", 2 * (s - 3) + 10 + (t / 5 + 1) * 2);
else
printf("%d", 10 + 3 * (s - 10)+20 + (t / 5 + 1) * 2);
} else if (t % 5 == 0) {
if (s > 3 && s <= 10)
printf("%d", 3 * (s - 10) + 30 + (t / 5) * 2);
else
printf("%d", 30 + 3 * (s - 10) + (t / 5));
}
}
return 0;
}
这个不太清楚呀