60分求助!!!!!!(C++)

P1422 小玉家的电费

您还是精确一些吧,66.9太粗了,可能其他部分加加减减就变成了了66.9四舍五入与66.945四舍五入值不一样。反正就,您可以试试。
by gtk_cy @ 2020-12-08 21:16:02


这是我当时的代码,您可以看看: ```c #include<iostream> #include<iomanip> using namespace std; int main() { int n; double sum; cin>>n; if(n<=150) { sum=(double)n*0.4463; cout<<fixed<<setprecision(1)<<sum<<endl; } if(n>=151&&n<=400) { sum=(1.0*150)*0.4463+((double)(n-150))*0.4663; cout<<fixed<<setprecision(1)<<sum<<endl; } if(n>=401) { sum=(1.0*150)*0.4463+(1.0*250)*0.4663+((double)(n-400))*0.5663; cout<<fixed<<setprecision(1)<<sum<<endl; } return 0; } ```
by gtk_cy @ 2020-12-08 21:17:26


|