inf是什么意思?为什么会出现这个? 第二张图中最后bmi结果为啥是整型显示,不应该是浮点型吗?

#include<iostream>
using namespace std;
int main()
{
const int x=12;
const double y=0.0254;
const double z=2.2;
cout<<"please write down your height:(_feet and_inch)and write down your weight(pounds)"<<endl;
int feet ,inch,pounds,meters,kiogram;
cin>>feet>>inch>>pounds;
inch=inch+x*feet;
meters=inch*y;
kiogram=pounds*z;
float bmi=(float) kiogram/(meters*meters);
cout<<"BMI is"<<' '<<bmi;

}

inf表示“无穷大 (infinity 的缩写)”。
原因为输入1/2/45这组数据会导致meters为0,使得
float bmi=(float) kiogram/(meters*meters);
这一句除数为零。
温馨提示:答案为网友推荐,仅供参考
相似回答