yangchenhao123 @ 2024-06-24 20:18:18
#include <bits/stdc++.h>
using namespace std;
int main()
{
int a;
cin>>a;
if(a<=150){
cout<<fixed<<setprecision(1)<<a*0.4463;
}else if(a<151&&a>400){
cout<<fixed<<setprecision(1)<<a*0.4663;
}else if(a>=401){
cout<<fixed<<setprecision(1)<<a*5663;
}
return 0;
}
by Grammar__hbw @ 2024-06-24 20:23:43
@yangchenhao123 首先,不是5663,是0.5663;其次,题目要求分段计费,不可以直接乘。
by WEICY123 @ 2024-06-24 20:31:44
#include <bits/stdc++.h>
using namespace std;
int main()
{
int a;
cin>>a;
if(a<=150){
cout<<fixed<<setprecision(1)<<a*0.4463;
}else if(a>=151&&a<=400){
cout<<fixed<<setprecision(1)<<150*0.4463+(a-150)*0.4663;
}else if(a>=401){
cout<<fixed<<setprecision(1)<<150*0.4463+250*0.4663+(a-400)*0.5663;
}
return 0;
}
@yangchenhao123 所以要改成这样
by yangchenhao123 @ 2024-06-25 12:53:22
谢谢