問題一覧
お問い合わせ
light_mode
dark_mode
残り時間:
00:00
速度:
0
文字/分
BMI計算 (C++)
問題
身長と体重からBMIを計算し、体型区分を表示するプログラムです。
入力例
170 64
出力例
あなたのBMIは 22.1 です 普通体重
スタート
参照コード
コピーはできません。自分でタイピングしてください。
#include <iostream> #include <iomanip> using namespace std; int main() { float height, weight, bmi; cin >> height; cin >> weight; height = height / 100.0; // cm to m bmi = weight / (height * height); cout << fixed << setprecision(1); cout << "あなたのBMIは " << bmi << " です" << endl; if (bmi < 18.5) { cout << "低体重" << endl; } else if (bmi < 25.0) { cout << "普通体重" << endl; } else if (bmi < 30.0) { cout << "肥満(1度)" << endl; } else { cout << "肥満(2度以上)" << endl; } return 0; }
入力エリア
コンパイル&実行
3