数据问题

Yang_ 2022-03-31 16:25:50 2022-03-31 16:26:08 4

本题的AC代码:

#include <iostream>

using namespace std;

int main() {
    int lucheng, shijian;
    double feiyong = 0.0;
    cin >> lucheng;

    if (lucheng > 10)
        feiyong = 6 + (10 - 2) * 1.8 + (lucheng - 10) * 1.8 * 1.5;
    else if (lucheng > 2 && lucheng <= 10)
        feiyong = 6 + (feiyong - 2) * 1.8;
    else if (lucheng <= 2 && lucheng >= 0)
        feiyong = 6;

    cin >> shijian;
    shijian = (shijian / 3) * 1;
    feiyong += shijian;
    printf("%.1lf", feiyong);

    return 0;
}

显然路程在2~10之间的写法是错误的。应该是: feiyong = 6 + (lucheng - 2) * 1.8;

{{ vote && vote.total.up }}

共 1 条回复

root 站长

fixed