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

你可能感兴趣的文章
php英语单词,php常用英语单词,快速学习php编程英语(6)
查看>>
R3.4.0安装包时报错“需要TRUE/FALSE值的地方不可以用缺少值”,需升级到R3.5.0
查看>>
PHP获取curl传输进度
查看>>
PHP获取IP所在地区(转)
查看>>
PHP获取IP的方法对比
查看>>
php获取json里面内容
查看>>
R2的版本由来
查看>>
PHP获取图片宽度高度、大小尺寸、图片类型、用于布局的img属性
查看>>
PHP获取当前时间、时间戳的各种格式写法汇总
查看>>
PHP获取当前页面的完整URL
查看>>
php获取文件夹中文件的两种方法
查看>>
PHP获取日期的一些方法总结
查看>>
R2学习记录
查看>>
PHP获取本周的每一天的时间
查看>>
php获取网页内容的三种方法
查看>>
R-CNN算法优化策略
查看>>
PHP规范PSR0和PSR4的理解
查看>>
php解析ipa包,获取logo
查看>>
php设置socket超时时间
查看>>
php设计模式 萨莱 pdf,PHP设计模式 建造者模式
查看>>