60分求助

P1422 小玉家的电费

@[ZXYRIC](/user/526356) 你的最后一个else语句中 n+=0.4663*(a-150); 有一点问题 两种解决方法 1.将(a-150)换成250 2.将(a-150)换成(a-150-400)
by xu_yi_cheng @ 2022-03-13 19:19:10


``` #include<bits/stdc++.h> using namespace std; double a,b,sum; int main(){ cin>>a; b=a; if(a<=150){ sum=sum+a*0.4463; } else if(a<=400 and a>=151){ sum=sum+(a-150)*0.4663+150*0.4463; } else{ sum=sum+(a-400)*0.5663; sum=sum+250*0.4663; sum=sum+150*0.4463; } cout<<fixed<<setprecision(1)<<sum; return 0; } ``` AC代码,不喜勿喷
by Ricardo_Sakura @ 2022-03-18 21:26:30


|