博客
关于我
磕代码: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实现双端队列算法(附完整源码)
查看>>
Objective-C实现双线性插值(附完整源码)
查看>>
Objective-C实现双重链表(附完整源码)
查看>>
Objective-C实现反向传播神经网络算法(附完整源码)
查看>>
Objective-C实现反转位算法(附完整源码)
查看>>
Objective-C实现反转字符串算法(附完整源码)
查看>>
Objective-C实现合并两棵二叉树算法(附完整源码)
查看>>
Objective-C实现向量叉乘(附完整源码)
查看>>
Objective-C实现哈希查找(附完整源码)
查看>>
Objective-C实现哈希表算法(附完整源码)
查看>>
Objective-C实现四舍五入(附完整源码)
查看>>
Objective-C实现四阶龙格库塔法(附完整源码)
查看>>
Objective-C实现四阶龙格库塔法(附完整源码)
查看>>
Objective-C实现回调实例(附完整源码)
查看>>
Objective-C实现图书借阅系统(附完整源码)
查看>>
Objective-C实现图像二维熵的图像信号丢失检测(附完整源码)
查看>>
Objective-C实现图像去雾算法(附完整源码)
查看>>
Objective-C实现图层混合算法(附完整源码)
查看>>
Objective-C实现图片erosion operation侵蚀操作算法(附完整源码)
查看>>
Objective-C实现图片的放大缩小(附完整源码)
查看>>