询问一下写法问题 c++
查看原帖
询问一下写法问题 c++
91757
BlakrPander楼主2020/10/11 11:54
#include<bits/stdc++.h>
using namespace std;
int main(){
	float wight=0,hight=0;
	float BMI;
	cin>>wight>>hight;
	BMI=wight/(hight*hight);
	if(BMI<18.5){
		cout<<"Underweight";
	}else if(BMI<=24){
		cout<<"Normal";
	}else{
		cout<<BMI<<endl<<"Overweight";
	}
	return 0;
}

如题,这之中的

BMI=wight/(hight*hight);

换成了

BMI=wight/hight*hight

就不能得出正确答案了,请问是为啥???

2020/10/11 11:54
加载中...