博客
关于我
磕代码: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/

你可能感兴趣的文章
Python eval 函数说明
查看>>
python eval简介
查看>>
python excel 饼图 简书_Python实现绘画多个饼图
查看>>
python excel接口自动化测试框架!
查看>>
Python exec 函数解析:探索动态代码执行的无限可能!
查看>>
Python EXEC和__NAME__
查看>>
Python exe文件打包神器-Nuitka!
查看>>
python file
查看>>
Python FileDialog获取文件夹路径不是文件
查看>>
python filter过滤器的使用_python基础知识分享:zip()、filter函数和reduce如何使用?...
查看>>
python flask 请求code 400, message Bad request version
查看>>
Python Flink Stateful函数入口上的Kafka键访问
查看>>
Python float - str - 浮动怪异
查看>>
Python Flower库:分布式任务管理与监控
查看>>
Python for 循环和迭代器行为
查看>>
Python For循环多次返回
查看>>
python frame_python3 selenium自动化 frame表单嵌套的切换方法
查看>>
Python ftplib - 指定端口
查看>>
Python furl库:一键搞定复杂URL操作
查看>>
Python GC 也会关闭文件吗?
查看>>