博客
关于我
磕代码:c/c++/java:输入身高体重,输出BMI区间。float类型的定义和使用
阅读量:83 次
发布时间:2019-02-26

本文共 1776 字,大约阅读时间需要 5 分钟。

???????????????

C????

#include 
int main() { int a, b; while(scanf("%d %d",&a,&b) != EOF) { float c = a / (b / 100.00) / (b / 100.00); if(c < 18.5) printf("Underweight"); else if(c >= 18.5 && c <= 23.9) printf("Normal"); else if(c > 23.9 && c <= 27.9) printf("Overweight"); else printf("Obese"); }}

C++????

#include 
#include
using namespace std;int main() { int a, b; while(cin >> a >> b) { float c = a / (b / 100.00) / (b / 100.00); if(c < 18.5) cout << "Underweight"; else if(c >= 18.5 && c <= 23.9) cout << "Normal"; else if(c > 23.9 && c <= 27.9) cout << "Overweight"; else cout << "Obese"; cout << endl; }}

Java????

import java.io.*;public class Main {    public static void main(String[] args) throws IOException {        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));        String s;        while((s = br.readLine()) != null) {            String[] sa = s.split(" ");            int a = Integer.parseInt(sa[0]);            int b = Integer.parseInt(sa[1]);            double c = a / (b * 0.01) / (b * 0.01);            if(c < 18.5)                System.out.println("Underweight");            else if(c <= 23.9 && c >= 18.5)                System.out.println("Normal");            else if(c <= 27.9 && c > 23.9)                System.out.println("Overweight");            else                System.out.println("Obese");        }    }}

?????????????????????????????????????????C???C++???????????Java?????????????????????????????a?b?????????????????????c = a / (b / 100.00) / (b / 100.00)??c = a * 10000 / (b^2)???c??????????????

转载地址:http://ewcz.baihongyu.com/

你可能感兴趣的文章
Objective-C实现MinimumCostPath最小成本路径算法(附完整源码)
查看>>
Objective-C实现min_heap最小堆算法(附完整源码)
查看>>
Objective-C实现mobius function莫比乌斯函数算法(附完整源码)
查看>>
Objective-C实现modular Binary Exponentiation模二进制指数算法 (附完整源码)
查看>>
Objective-C实现modular exponential模指数算法(附完整源码)
查看>>
Objective-C实现monte carlo dice蒙特卡洛骰子模拟算法(附完整源码)
查看>>
Objective-C实现monte carlo蒙特卡罗算法(附完整源码)
查看>>
Objective-C实现Mosaic Augmentation马赛克增强算法(附完整源码)
查看>>
Objective-C实现msd 基数排序算法(附完整源码)
查看>>
Objective-C实现MSRCR算法(附完整源码)
查看>>
Objective-C实现multi level feedback queue多级反馈队列算法(附完整源码)
查看>>
Objective-C实现multilayer perceptron classifier多层感知器分类器算法(附完整源码)
查看>>
Objective-C实现multiplesThreeAndFive三或五倍数的算法 (附完整源码)
查看>>
Objective-C实现n body simulationn体模拟算法(附完整源码)
查看>>
Objective-C实现naive string search字符串搜索算法(附完整源码)
查看>>
Objective-C实现natural sort自然排序算法(附完整源码)
查看>>
Objective-C实现nested brackets嵌套括号算法(附完整源码)
查看>>
Objective-C实现nevilles method多项式插值算法(附完整源码)
查看>>
Objective-C实现newton raphson牛顿-拉夫森算法(附完整源码)
查看>>
Objective-C实现newtons second law of motion牛顿第二运动定律算法(附完整源码)
查看>>