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

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

在这里插入图片描述

在这里插入图片描述
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\n"); else if(c>=18.5&&c<=23.9)printf("Normal\n"); else if(c>23.9&&c<=27.9)printf("Overweight\n"); else printf("Obese\n"); }}

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.0&&c<=27.9)cout<<"Overweight"; else cout<<"Obese"; cout<

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");        }    }}//           float b=Float.parseFloat(sa[1]);            double c=a*10000/(b*b);

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

你可能感兴趣的文章
mysql第二天~mysql基础【查询排序、分页查询、多表查询、数据备份与恢复等】
查看>>
MySQL简单查询
查看>>
MySQL管理利器 MySQL Utilities 安装
查看>>
mysql类型转换函数convert与cast的用法
查看>>
mysql系列一
查看>>
MySQL系列之数据类型(Date&Time)
查看>>
Mysql系列之锁机制
查看>>
Mysql系列九:使用zookeeper管理远程Mycat配置文件、Mycat监控、Mycat数据迁移(扩容)...
查看>>
Mysql索引
查看>>
mysql索引
查看>>
mysql索引
查看>>
Mysql索引,索引的优化,如何避免索引失效案例
查看>>
Mysql索引、命令重点介绍
查看>>
mysql索引、索引优化(这一篇包括所有)
查看>>
MySQL索引一篇带你彻底搞懂(一次讲清实现原理加优化实战,面试必问)
查看>>
MySql索引为什么使用B+树
查看>>
WARNING!VisualDDK wizard was unable to find any DDK/WDK installed on your system.
查看>>
Mysql索引优化
查看>>
MySQl索引创建
查看>>
mysql索引创建及使用注意事项
查看>>