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

你可能感兴趣的文章
oauth2登录认证之SpringSecurity源码分析
查看>>
OAuth2:项目演示-模拟微信授权登录京东
查看>>
OA系统多少钱?OA办公系统中的价格选型
查看>>
OA系统选型:选择好的工作流引擎
查看>>
OA让企业业务流程管理科学有“据”
查看>>
OA项目之会议通知(查询&是否参会&反馈详情)
查看>>
Vue.js 学习总结(13)—— Vue3 version 计数介绍
查看>>
OA项目之我的会议(会议排座&送审)
查看>>
OA项目之我的会议(查询)
查看>>
OA项目之我的审批(会议查询&会议签字)
查看>>
OA项目之项目简介&会议发布
查看>>
ObjC的复制操作
查看>>
Object c将一个double值转换为时间格式
查看>>
object detection之Win10配置
查看>>
object detection训练自己数据
查看>>
object detection错误Message type "object_detection.protos.SsdFeatureExtractor" has no field named "bat
查看>>
object detection错误之Could not create cudnn handle: CUDNN_STATUS_INTERNAL_ERROR
查看>>
object detection错误之no module named nets
查看>>
Object of type 'ndarray' is not JSON serializable
查看>>
Object Oriented Programming in JavaScript
查看>>