Rmghcz @ 2023-07-20 22:22:36
#include<iostream>
using namespace std;
double i,sum;
int main()
{
cin>>i;
if(i<=150)
{
sum=i*0.4463;
printf("%.1f",sum);
}
else if(i>=151&&i<=400)
{
sum=150*0.4463+(i-150)*0.4663;
printf("%.1f",sum);
}
else
{
sum=150*0.4463+400*0.4663+(i-400)*0.5663;
printf("%.1f",sum);
}
return 0;
}
by bk1212 @ 2023-07-20 22:49:09
@Rmghcz
sum=150*0.4463+400*0.4663+(i-400)*0.5663;
这行代码写错了哦,应该写为
sum=150*0.4463+250*0.4663+(i-400)*0.5663;
因为他是151~400这个范围的电费是
by __LiChangChao__ @ 2023-07-20 22:52:35
@Rmghcz
400*0.4663
by Rmghcz @ 2023-07-20 22:53:08
@bk1212 好滴,谢谢!
by Rmghcz @ 2023-07-20 22:56:36
@changwenxuan不好意思,我太粗心了,当时没有考虑这个