计算体重系数

计算体重指数

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

总结:

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

全部评论

相关推荐

点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务