Calarence4 @ 2023-07-22 15:08:38
#include<bits/stdc++.h>
using namespace std;
int n;
double s;
int main()
{
cin>>n;
if(n<=150)
s=0.4463*n;
if(n>=151&&n<=400)
s=0.4463*150+(n-150)*0.4663;
else
s=0.4463*150+(400-150)*0.4663+(n-400)*0.5663;
printf("%.1f",s);
}
by tommy790605 @ 2023-07-22 15:32:45
第二个if用else if。s<=150的时候会被最后一个else重置而错误
by tommy790605 @ 2023-07-22 15:35:28
else if(n>=151&&n<=400)
by kuailehaoge2024 @ 2023-08-19 10:56:11
#include<bits/stdc++.h>
using namespace std;
int n;
double s;
int main(){
cin>>n;
if(n<=150){
s=0.4463*n;
}else if(n>=151&&n<=400){
s=0.4463*150+(n-150)*0.4663;
}else{
s=0.4463*150+(400-150)*0.4663+(n-400)*0.5663;
}
printf("%.1f",s);
}