方法一:
int main(void)
{
int a = 0, b = 0;
float c = 0;
scanf("%d %d", &a, &b);
c=(float)b / 100;//将b强制转化为float
c *= c;
c = a /c;
printf("%0.2f", c);//%0.2f意味着小数点后保持两位
//后续我会发一个帖子,详细介绍C语言——%d,%-7d,%7d,%07d的区别,到时候可以点我主页看
return 0;
}
方法二:
int main()
{
int weight = 0;
int height = 0;
double bmi = 0.0;
scanf("%d%d", &weight, &height);
bmi = weight/((double)height*height/10000);
printf("%.2lf\n", bmi);
return 0;
}