c++20分

P1422 小玉家的电费

就算超过150,150以内的部分仍然是0.4463元
by jhdrgfj @ 2023-01-03 10:27:07


``` #include<iostream> #include<iomanip> #include<algorithm> #include<cmath> #include<string> using namespace std; int main() { int n, a, b, c; cin >> n; if (n <= 150) { a = n; cout <<fixed<<setprecision(1)<< 0.4463 * a * 1.0; return 0; } else { a = 150; if (n <= 400) { b = n - 150; cout << fixed << setprecision(1) << 0.4663 * b * 1.0 + 0.4463 * a * 1.0; return 0; } else { b = 400 - 150; c = n - 400; cout << fixed << setprecision(1) << 0.4663 * b * 1.0 + 0.4463 * a * 1.0 + 0.5663 * c * 1.0; } } return 0; } ```
by Hongzixuan0922 @ 2023-01-03 10:29:58


谢谢,过了
by 13813675795hzq @ 2023-01-03 11:18:16


|