计算体重系数

计算体重指数

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;
}

总结:

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

全部评论

相关推荐

06-26 19:47
中南大学 Java
点赞 评论 收藏
分享
屌丝逆袭咸鱼计划:心态摆好,man,晚点找早点找到最后都是为了提升自己好进正职,努力提升自己才是最关键的😤难道说现在找不到找的太晚了就炸了可以鸡鸡了吗😤早实习晚实习不都是为了以后多积累,大四学长有的秋招进的也不妨碍有的春招进,人生就这样
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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