Closed roberthsu2003 closed 7 months ago
#include <iostream>
#include <math.h>
// C語言的某個數學庫
using namespace std;
int main() {
cout << "BMI值計算公式: BMI = 體重(公斤) / 身高2(公尺2)" << endl;
double A,B;
double C,BMI;
cout << "請輸入身高(公分):";
cin >> B;
cout << "請輸入體重(公斤):";
cin >> A;
//跟高公分轉換成公尺單位
C = B/100.0;
///BMI的公式
///pow 為 pow(double,double) 計算 前數字 的後 平方
BMI = (A/pow(C,2));
cout << "\n您的BMI為 " << BMI << "\n您的體重:";
// 根據BMI給予不同的提醒..
if (BMI < 18.5)
{
cout << "體重過輕\n";
}
else if (BMI < 24)
{
cout << "正常範圍\n";
}
else if (BMI < 27)
{
cout << "過重\n";
}
else if (BMI < 30)
{
cout << "輕度肥胖\n";
}
else if (BMI < 35)
{
cout << "中度肥胖\n";
}
else
{
cout << "重度肥胖\n";
}
cout << "\n【BMI範圍參考】\n體重過輕:BMI < 18.5\n正常範圍18.5≦BMI<24\n過重:24≦BMI<27\n輕度肥胖:27≦BMI<30\n中度肥胖:30≦BMI<35\n重度肥胖:BMI≧35\n";
}
#include <iostream>
using namespace std;
int main() {
int cm,kg;
float m,bmi;
cout<<"請輸入身高(公分):";
cin>>cm;
cout<<"請輸入體重(公斤):";
cin>>kg;
m=cm/100.0;
bmi=kg/(m*m);
cout<<"您的BMI是:"<<bmi<<endl;
if(bmi>=18.5 && bmi<24){
cout<<"您的體重:正常";
}else if(bmi>=24 && bmi<27){
cout<<"您的體重:過重";
}else if(bmi>=27 && bmi<30){
cout<<"您的體重:輕度肥胖";
}else if(bmi>=30 && bmi<35){
cout<<"您的體重:中度肥胖";
}else if(bmi>=35){
cout<<"您的體重:重度肥胖";
}else{
cout<<"您的體重:過輕";
}
}
#include <iostream>
using namespace std;
int main() {
double h,w,bmi;
cout<<"請輸入身高(公分)";
cin>>h;
cout<<"請輸入體重(公斤)"<<endl;
cin>>w;
bmi=w/((h/100)*(h/100));
cout<<"你的BMI值為"<<bmi<<endl;
if (bmi<18.5)
{cout<<"體重過輕"<<endl;}
else if(bmi>=18.5&&bmi<24)
{cout<<"體重正常"<<endl;}
else if(bmi>=24&&bmi<27)
{cout<<"過重"<<endl;}
else if(bmi>=27&&bmi<30)
{cout<<"輕度肥胖"<<endl;}
else if(bmi>=30&&bmi<35)
{cout<<"中度肥胖"<<endl;}
else
{cout<<"重度肥胖"<<endl;}
}
#include <iostream>
#include <math.h>
using namespace std;
int main() {
int bodyHigh,bodyWeight;
float bodyBMI;
cout << "請輸入你的身高(公分)、體重(公斤):";
cin >> bodyHigh >> bodyWeight;
bodyBMI = bodyWeight/pow(bodyHigh/100.0,2);
cout << "你的BMI值為:" << bodyBMI;
if (bodyBMI >= 35){
cout << ",重度肥胖\n";
}
else if (bodyBMI >= 30 && bodyBMI < 35){
cout << ",中度肥胖\n";
}else if (bodyBMI >= 27 && bodyBMI < 30){
cout << ",輕度肥胖\n";
}else if (bodyBMI >= 24 && bodyBMI < 27){
cout << ",過重\n";
}else if (bodyBMI >= 18.5 && bodyBMI < 24){
cout << ",正常\n";
}else {cout << ",過輕\n";}
}
#include <iostream>
#include <math.h>
using namespace std;
int main() {
double tal, wei, bmi;
cout << "請輸入身高(公分):";
cin >> tal;
tal /= 100;
cout << "請輸入體重(公斤):";
cin >> wei;
bmi = wei / pow(tal,2);
printf("\n您的BMI:%.2lf\n", bmi);
if(bmi < 18.5) cout << "您的體重:過輕" << endl;
else if(18.5 <= bmi && bmi < 24) cout << "您的體重:正常" << endl;
else {
if(24 <= bmi && bmi < 27) cout << "您的體重:過重" << endl;
else if(27 <= bmi && bmi < 30) cout << "您的體重:過重(屬於輕度肥胖)" << endl;
else if(30 <= bmi && bmi < 35) cout << "您的體重:過重(屬於中度肥胖)" << endl;
else cout << "您的體重:過重(屬於重度肥胖)" << endl;
cout << "\n男性腰圍 >= 90cm 女性腰圍 >= 80cm" << endl;
}
return 0;
}
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
double height, kg, bmi;
int main() {
cout << "請輸入您的身高(單位:公分)\n";
cin >> height;
cout << "請輸入您的體重(單位:公斤)\n";
cin >> kg;
bmi = kg / pow(height / 100, 2);
cout << "您的BMI為" << fixed << setprecision(2) << bmi << endl;
if (bmi >= 35) {
cout << "重度肥胖";
} else if (bmi >= 30) {
cout << "中度肥胖";
} else if (bmi >= 27) {
cout << "輕度肥胖";
} else if (bmi <= 18.5) {
cout << "過輕";
}
return 0;
}
#include <iostream>
using namespace std;
int main() {
double weight, height, BMI;
cout << "___BMI檢測___" << endl;
cout << "請輸入您的體重(公斤):";
cin >> weight;
cout << "請輸入您的身高(公分):";
cin >> height;
BMI = weight / (height / 100 * height /100);
cout << "您的BMI數值為:" << BMI << endl;
if (BMI < 18.5){
cout << "體重過輕\n";
} else if (BMI >= 18.5 && BMI < 24){
cout << "正常範圍\n";
} else if (BMI >= 24 && BMI <27){
cout << "過重\n";
} else if (BMI >= 27 && BMI <30){
cout << "輕度肥胖\n";
} else if (BMI >= 30 && BMI <35){
cout << "中度肥胖\n";
} else {
cout << "重度肥胖\n";
}
return 0;
}
#include <iostream>
using namespace std;
int main() {
double w, h, BMI;
cout << "請輸入體重(公斤): ";
cin >> w;
cout << "請輸入身高(公分): ";
cin >> h;
BMI = w / (h/100 * h/100);
cout << "您的BMI:" << BMI << endl;
cout << "您的體重:";
if (BMI < 18.5){
cout << "體重過輕";
}else if (BMI>=18.5 && BMI < 24){
cout << "正常範圍";
}else if (BMI>=24 && BMI < 27){
cout << "過重";
}else if (BMI>=27 && BMI < 30){
cout << "輕度肥胖";
}else if (BMI>30 && BMI < 35){
cout << "中度肥胖";
}else if (BMI>=35){
cout << "重度肥胖";
}
}
輸入:
輸出: