#include <stdio.h>

int main() {
    float distance;
    float fare;
    
    scanf("%f", &distance);
    
    if (distance <= 3) {
        fare = 10;
    } else if (distance <= 5) {
        fare = 10 + (distance - 3) * 1.8;
    } else {
        fare = 10 + 2 * 1.8 + (distance - 5) * 2.7;
    }
    
    printf("%.2f\n", fare);
    
    return 0;
}

注:此程序假设输入的里程数不会超过10公里。如果里程数可能超过10公里,可以使用循环来处理。


原文地址: http://www.cveoy.top/t/topic/hEJc 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录