首页 > 试题广场 >

计算体重指数

[编程题]计算体重指数
  • 热度指数:46585 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 32M,其他语言64M
  • 算法知识视频讲解

问题:计算BMI指数(身体质量指数)。BMI指数(即身体质量指数,简称体质指数又称体重,英文为Body Mass Index,简称BMI),是用体重公斤数除以身高米数平方得出的数字,是目前国际上常用的衡量人体胖瘦程度以及是否健康的一个标准。主要用于统计用途,当我们需要比较及分析一个人的体重对于不同高度的人所带来的健康影响时,BMI是一个中立而可靠的指标

数据范围:输入的数据满足


输入描述:
一行,两个整数,分别表示体重(公斤),身高(厘米),中间用一个空格分隔。


输出描述:
一行,BMI指数(保留两位小数)。
示例1

输入

70 170

输出

24.22
#include <stdio.h>

int main() {
    int weight=0;
    int hight=0;
    float BMI=0.0f;
    scanf("%d %d",&weight,&hight);
    BMI=weight/((hight/100.0)*(hight/100.0));
    printf("%.2f\n",BMI);
    return 0;
}

发表于 2024-04-13 09:18:52 回复(0)
#include <stdio.h>
#include <math.h>

int main() 
{
    int height = 0;
    int weight = 0;
    float bmi = 0.0f;
    
    scanf("%d%d", &weight, &height);

    //录入的身高是m,计算的身高是cm,记得换算
    bmi = (float)weight / pow((height / 100.0), 2);

    printf("%.2f", bmi);

    return 0;
}

发表于 2024-03-18 15:52:53 回复(0)
#include<stdio.h>
int main()
{
    int a = 0;
    float b = 0;
    scanf("%d %f", &a, &b);
    b /= 100;
    float BMI = a / (b * b);
    printf("%.2f", BMI);
    return 0;
}
发表于 2023-07-05 15:36:54 回复(0)
#include <stdio.h>
int main()
{

	float a = 0;//a为体重,单位为公斤

	float b = 0;//b为身高,单位为厘米

	float B = 0;

	float C = 0;

	scanf("%f %f", &a, &b);

	B = b / 100;//此处将输入的身高单位厘米换算成米。
	C = B * B;
	float BMI = a / C;

	printf("%.2f", BMI);//.2f是指将BMI以单精度浮点型打印出来并且保留两位小小数

	return 0;
}

发表于 2023-06-16 13:44:17 回复(0)
#include <stdio.h>

int main() 
{
	int h = 0;
	int w = 0;
	float BMI = 0.00;
	scanf("%d %d",&w,&h);
	BMI = (float)w / (float)(h*h);
	printf("%.2lf\n",BMI*10000);
	return 0;
}

发表于 2023-06-16 12:00:25 回复(0)
#include <stdio.h>

int main()
{
    float a,b;
    scanf("%f %f",&a,&b);
    float c=b/100;
    printf("%.2f",a/c/c);
    return 0;
}
发表于 2023-04-10 00:53:57 回复(0)
#include <stdio.h>

int main() {
    float a,b;
    scanf("%f %f",&a,&b);
    float c=(b/100)*(b/100);
    printf("%.2f",a/c);
    return 0;
}

发表于 2023-03-06 22:22:54 回复(1)
#include <stdio.h>

int main() 
{
    int weight = 0;
    int high = 0;
    double BMI = 0.0;
    scanf("%d %d",&weight,&high);
    BMI = (weight/((high/100.0)*((high/100.0))));
    printf("%.2f",BMI);
    return 0;
}

发表于 2023-01-28 14:09:47 回复(0)
#include<stdio.h>
int main()
{
   int weight=0;
   int height=0;
    double BMI=0;
    scanf("%d %d",&weight,&height);
    
    BMI=weight/(((float)height/100)*((float)height/100));
    printf("%.2f\n",BMI);
    
    
    return 0;
}

发表于 2022-05-12 11:45:57 回复(0)
#include<stdio.h>
#include<math.h>
int main()
{
    int a,b;
    float c,d,x;
    scanf("%d %d",&a,&b);
    x = (1.0*b)/100;
    c = pow(x,2);
    d = 1.0*a/c;
    printf("%.2f",d);
    return 0;
}
发表于 2022-04-17 20:40:18 回复(0)
#include<stdio.h>
int main(int argc,char *argv[]){
    float w,h;
    float BMI;
    scanf("%f %f",&w,&h);
    BMI = w/((h/100)*(h/100));
    printf("%.2f",BMI);
    return 0;
}

发表于 2022-02-13 09:28:47 回复(0)
#include<stdio.h>
int main(void){
    int high, height;  // 根据题目要求,体重和身高都是整数
    float bmi;  // 由示例可以看出BMI是浮点数
    
    scanf("%d %d", &height, &high);  // 用来存储身高和体重的值
    
    bmi = height / (high * high / 10000.0);  // 求BMI,注意:这里的身高为整数且是厘米,所以需要转化
    
    printf("%.2f\n", bmi);  // 打印保留了2位有效数字的 BMI
    
    return 0;
}
求BMI,注意:这里的身高为整数且是厘米,所以需要转化
发表于 2022-01-29 11:00:13 回复(0)
#include<stdio.h>
int  main()
{
    int w,h;
    float hm;
    scanf("%d %d",&w,&h);
    hm=h/100.0;
    printf("%.2f",w/(float)(hm*hm));
    return 0;
}
发表于 2022-01-19 18:42:59 回复(0)
#include<stdio.h>
#include<math.h>
int main()
{
    int w,h;
    
    scanf("%d %d",&w,&h);
    printf("%.2f",w/pow(h*0.01,2));
    
    return 0;
}
发表于 2022-01-15 21:55:00 回复(0)
int main()
{
    int a,b;
    scanf("%d %d",&a,&b);
    printf("%.2f",a/(((float)b/100)*((float)b/100)));
    return 0;
}
发表于 2022-01-12 11:03:19 回复(0)
#include<stdio.h>
#include<math.h>
int main(){
    float kg;
    float cm;
    float BMI;
    scanf("%f %f",&kg,&cm );
    cm=cm/100;
    BMI=kg/pow(cm,2);
    printf("%.2f",BMI);
    return 0;
    
    
    
    
    
}

发表于 2021-12-17 23:32:55 回复(0)
我认为对我来说要注意的是身高除以的是100.0
发表于 2021-12-14 16:45:41 回复(0)
#include"stdio.h"
int main(){
    float weight,height;
    scanf("%f %f",&weight,&height);
    float high;
    high=height/100;
    printf("%.2f",weight/(high*high));
    return 0;
}
发表于 2021-11-25 19:41:04 回复(0)
#include<stdio.h>
#include<math.h>
int main()
{
    int weight,height;
    float bmi;
    scanf("%d %d",&weight,&height);
    bmi=weight/pow((height/100.0),2);
    printf("%.2f",bmi);
    return 0;
}
发表于 2021-10-29 21:26:21 回复(0)
#include<stdio.h>
int main()
{
    int kg,cm;
    float m;
    scanf("%d %d",&kg,&cm);
    m=(double)cm/100;
    printf("%.2lf",kg/(m*m));
    return 0;
}

发表于 2021-10-22 18:05:47 回复(0)

问题信息

上传者:牛客309119号
难度:
26条回答 3948浏览

热门推荐

通过挑战的用户

查看代码
计算体重指数