月考炸了,没心情写题解了。兄弟们直接看代码吧。
代码如下(C):
#include <stdio.h>
int main(void)
{
int ekwh = 0;
float qian;
scanf("%d", &ekwh);
if (ekwh <= 150) {
qian = 0.4463 * ekwh;
printf("%.1f
", qian);
} else if(ekwh > 150 && ekwh <= 400) {
qian = 0.4463 * 150 + 0.4663 * (ekwh - 150);
printf("%.1f
", qian);
} else if(ekwh > 400) {
qian = 0.4463 * 150 + 0.4663 * 250 + 0.5663 * (ekwh - 400);
printf("%.1f
", qian);
} else {
printf("
");
}
return 0;
}