@[Huyuhao0215](/user/916579)
请注意细节(⊙o⊙)
题目中 :月用电量在150千瓦时及以下部分按每千瓦时 0.4463 元执行 ###还没有使用到哦
可以参照我的代码,用if - else结构,分层次考虑交电费。如下:
```c
#include <bits/stdc++.h>
using namespace std;
int main() {
double n, s = 0;
scanf("%lf", &n);
if(n <= 150) {
s += (n * 0.4463);
}
else if(n <= 400) {
s += (150 * 0.4463);
s += ((n - 150) * 0.4663);
}
else {
s += (150 * 0.4463);
s += (250 * 0.4663);
s += ((n - 400) * 0.5663);
}
printf("%.1lf", s);
return 0;
}
\(@^0^@)/
by midsummer_zyl @ 2023-06-24 14:33:54
@[zyl2011](/user/1025321) 等一下,我好像能看到别人源代码?
by GoodLuckCat @ 2023-06-24 21:02:32
谢谢,关注你了
by GoodLuckCat @ 2023-06-24 21:03:56
不用谢!!
by midsummer_zyl @ 2023-06-24 21:14:55
kaogu
by GoodLuckCat @ 2023-09-08 18:03:43