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

你可能感兴趣的文章
Navicate for mysql 数据库设计-数据库分析
查看>>
Navicat下载和破解以及使用
查看>>
Navicat中怎样将SQLServer的表复制到MySql中
查看>>
navicat创建连接 2002-can‘t connect to server on localhost(10061)且mysql服务已启动问题
查看>>
Navicat可视化界面导入SQL文件生成数据库表
查看>>
Navicat向sqlserver中插入数据时提示:当 IDENTITY_INSERT 设置为 OFF 时,不能向表中的标识列插入显式值
查看>>
Navicat因导入的sql文件中时间数据类型有参数而报错的原因(例:datetime(3))
查看>>
Navicat如何连接MySQL
查看>>
navicat导入.sql文件出错2006- MySQLserver has gone away
查看>>
Navicat导入海量Excel数据到数据库(简易介绍)
查看>>
Navicat工具Oracle数据库复制 or 备用、恢复功能(评论都在谈论需要教)
查看>>
navicat工具查看MySQL数据库_表占用容量_占用空间是多少MB---Linux工作笔记048
查看>>
navicat怎么导出和导入数据表
查看>>
Navicat报错connection is being used
查看>>
Navicat报错:1045-Access denied for user root@localhost(using passwordYES)
查看>>
Navicat控制mysql用户权限
查看>>
navicat操作mysql中某一张表后, 读表时一直显示正在载入,卡死不动,无法操作
查看>>
Navicat连接mysql 2003 - Can't connect to MySQL server on ' '(10038)
查看>>
Navicat连接mysql数据库中出现的所有问题解决方案(全)
查看>>
Navicat连接Oracle出现Oracle library is not loaded的解决方法
查看>>