CroxNither_QAQ @ 2023-04-27 22:34:39
#include<iostream>
#include<cstring>
//#include<cmath>
//#include<algorithm>
//#include<iomanip> cout<<fixed<<setprecision()
using namespace std;
int main(){
int a;double n;
cin>>a;
if(a<=0){
cout<<0;
return 0;
}
if(a<=150){
n+=a*0.4463;
printf("%.1lf",n);
}else if(a>=151 && a<=400){
n+=0.4463*150;
n+=(a-150)*0.4663;
printf("%.1lf",n);
}else if(a>401){
n=0.4463*150+249*0.4663+(a-401)*0.5663;
printf("%.1lf",n);
}
return 0;
}
by wangcaizsr @ 2023-04-27 22:48:21
你那道题不是还没AC吗?
by wangcaizsr @ 2023-04-27 22:48:59
BMI那个
by jiangxinyang2012 @ 2023-04-28 08:46:29
@CroxNither_QAQ
#include<iostream>
#include<cstring>
//#include<cmath>
//#include<algorithm>
//#include<iomanip> cout<<fixed<<setprecision()
using namespace std;
int main(){
int a;double n=0;
cin>>a;
if(a<=0){
cout<<0;
return 0;
}
if(a<=150){
n+=a*0.4463;
printf("%.1lf",n);
}else if(a>=151 && a<=400){
n+=0.4463*150;
n+=(a-150)*0.4663;
printf("%.1lf",n);
}else if(a>=401){
n=0.4463*150+250*0.4663+(a-400)*0.5663;
printf("%.1lf",n);
}
return 0;
}
by jiangxinyang2012 @ 2023-04-28 08:49:52
1.你的n没赋0
2.
else if(a>401){
n=0.4463*150+249*0.4663+(a-401)*0.5663;
printf("%.1lf",n);
}
这一段应该改成
else if(a>=401){
n=0.4463*150+250*0.4663+(a-400)*0.5663;
printf("%.1lf",n);
}
by CroxNither_QAQ @ 2023-04-28 13:02:58
@2021Changqing60 谢谢大佬!