计算体重系数

计算体重指数

http://www.nowcoder.com/questionTerminal/422f6341cf1b4212a7f8c703df111389

分析:

题目简单,读入体重和身高带入公式计算即可得出结果,控制输出结果即可。

题解:

#include <bits/stdc++.h>
using namespace std;

int main() {
    int weight = 0, height = 0;
    scanf("%d %d", &weight, &height);
    printf("%.2f\n", weight / (height/100.f * height/100.f));
    return 0;
}

题解2:

#include <bits/stdc++.h>
using namespace std;

int main() {
    int weight = 0, height = 0;
    cin >> weight >> height;
    cout << setprecision(4) << weight / (height/100. * height/100.) << endl;
    return 0;
}

总结:

格式输出控制和简单表达式的计算。

全部评论
注意单位换算!先把身高的厘米转换为米后在进行计算!!!
点赞 回复 分享
发布于 2021-09-23 22:56

相关推荐

27届学院本誓死冲击...:自我评价和校园经历全删了,荣誉经历只留奖学金,项目也全得换都不如外卖
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
正在热议
更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务