阶梯电价
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/ef011f04aabe01e7a488175ab3393691.png)
#include<stdio.h>
int main(void)
{
int x;
double cost;
scanf("%d", &x);
if(x > 50){
cost = 50*0.53+(x-50)*0.58;
printf("cost = %.2f", cost);
}
else if(x>0){
cost = 0.53*x;
printf("cost = %.2f", cost);
}
else
printf("Invalid Value!\n");
return 0;
}
易错点:用电量是整数,用int定义(注意读题中隐含条件)