Baekjoon Online Judge
6825번: Body Mass Index
The Body Mass Index (BMI) is one of the calculations used by doctors to assess an adult’s health. The doctor measures the patient’s height (in metres) and weight (in kilograms), then calculates the BMI using the formula BMI = weight/(height × height).
www.acmicpc.net
[문제]
The Body Mass Index (BMI) is one of the calculations used by doctors to assess an adult’s health. The doctor measures the patient’s height (in metres) and weight (in kilograms), then calculates the BMI using the formula
BMI = weight/(height × height).
Write a program which prompts for the patient’s height and weight, calculates the BMI, and displays the corresponding message from the table below.
[코드]
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
double w, h;
cin >> w >> h;
if (w / pow(h, 2) > 25)
cout << "Overweight" << '\n';
else if (w / pow(h, 2) > 18.5)
cout << "Normal weight" << '\n';
else
cout << "Underweight" << '\n';
return 0;
}
'Baekjoon > C++' 카테고리의 다른 글
[C++][BOJ/백준] 31090 2023은 무엇이 특별할까? (0) | 2024.04.24 |
---|---|
[C++][BOJ/백준] 30501 관공... 어찌하여 목만 오셨소... (0) | 2024.04.22 |
[C++][BOJ/백준] 24083 短針 (Hour Hand) (2) | 2024.04.19 |
[C++][BOJ/백준] 30031 지폐 세기 (0) | 2024.04.19 |
[C++][BOJ/백준] 30468 호반우가 학교에 지각한 이유 1 (0) | 2024.04.17 |