博客
关于我
磕代码: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数据库进阶操作
查看>>
MySQL数据库配置文件调优详解
查看>>
MySQL数据库酒店客房管理系统(含MySQL源码) 结课作业 做的不是很好
查看>>
mysql数据库里的一些坑(读高性能mysql有感)
查看>>
MySQL数据库面试题(2021最新版)
查看>>
MySQL数据库高并发优化配置
查看>>
mysql数据恢复
查看>>
MySQL数据的主从复制、半同步复制和主主复制详解
查看>>
mysql数据碎片整理
查看>>
MySQL数据类型
查看>>
MySQL数据类型字节长度
查看>>
mysql数据被误删的恢复方案
查看>>
MySQL数据读写分离(MaxScale)上干货!!!
查看>>
mysql整库导入、导出
查看>>
mysql文本函数和数字函数
查看>>
Mysql新建用户和数据库并授权
查看>>