Problem J. S05-12 体型判断

医务工作者经广泛的调查和统计分析,根据身高与体重因素给出了以下按“体指数”进行体型判断的方法: 体指数 t = 体重w / (身高h)^2 (w单位为干克,h单位为米)体指数t=体重w/(身高h)2(w单位为干克,h单位为米)

  • 当t<18时,为低体重;
  • 当t介于18和25之间时,为正常体重,
  • 当t介于25和27之间时,为超重体重,
  • 当t≥27时,为肥胖。 编写程序判断系统给出的体重属于何种类型。

输入

两个浮点数,分别表示身高和体重

输出

too thintoothin, normalnormal, over weightoverweight, fatfat,四种输出分别对应四种类型

样例

标准输入复制文本
1.7  50
标准输出复制文本
too thin
标准输入复制文本
1.7  60
标准输出复制文本
normal
标准输入复制文本
1.7  75
标准输出复制文本
overweight

#include <iostream>
using namespace std;
int main() 
{
	double t,w,h;
	cin>>h>>w;
	t=w/(h*h);
	
	if(t<18) 
	{
		cout<<"too thin"<<endl;
	} 
	
	else if(t>=18&&t<25) 
	{
		cout<<"normal"<<endl;
	} 
	
	else if(t>=25&&t<27) 
	{
		cout<<"overweight"<<endl;
	} 
	
	else if ( t >=27 ) 
	{
		cout<<"fat"<<endl;
	}
	return 0;
}

posted @ 2022-10-03 18:58  131452lin  阅读(43)  评论(0编辑  收藏  举报