>月用电量在151~400千瓦时的部分按每千瓦时0.4663元执行
by _Remake_ @ 2022-04-04 21:45:05
150千瓦时及以下的部分按0.4463元/千瓦时计算
by _Remake_ @ 2022-04-04 21:45:38
你看看我的
```cpp
#include<iostream>
#include<iomanip>
using namespace std;
int main() {
int n;//用电量
double sum = 0;
cin >> n;
cout.setf(ios::fixed);
if (n <= 150) {
sum = n * 0.4463;
}
if (n > 150 && n <= 400) {
sum = 150 * 0.4463 + (n - 150) * 0.4663;
}
if (n > 400) {
sum = 150 * 0.4463 + 250 * 0.4663 + (n - 400) * 0.5663;
}
cout << fixed << setprecision(1) << sum << endl;
return 0;
}
```
by lylm1130 @ 2022-04-19 16:40:45
@lylm1130,你不对
by WYZqaq @ 2022-05-11 12:55:34
python也可以参考一下吗?
~~~~
a = int(input())
b = 150 * 0.4463
c = 250 * 0.4663
if a <= 150:
print(round(a * 0.4463, 1))
elif a > 150 and a <= 400:
print(round(b + (a - 150) * 0.4663, 1))
else:
print(round(b + c + (a - 400) * 0.5663, 1))
~~~~
代码如上↑
by ronkeyson @ 2022-06-22 21:42:00