본문 바로가기
  • Let's study
PS/백준

[C++] 백준 6825: Body Mass Index

by 코딩고수이고파 2023. 5. 14.

문제

https://www.acmicpc.net/problem/6825

 

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

 

해결방법

입력은 몸무게(w), 키(h) 순이며 w / (h * h)bmi를 구해 조건에 따라 출력한다.

 

코드

#include<iostream>

using namespace std;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	double h, w;
	cin >> w >> h;

	double bmi = w / (h*h);

	if (bmi > 25)
		cout << "Overweight";
	else if (bmi < 18.5)
		cout << "Underweight";
	else
		cout << "Normal weight";

	return 0;
}

'PS > 백준' 카테고리의 다른 글

[C++] 백준 27890: 특별한 작은 분수  (1) 2023.05.16
[C++] 백준 5358: Football Team  (0) 2023.05.15
[C++] 백준 25784: Easy-to-Solve Expressions  (0) 2023.05.13
[C++] 백준 6887: Squares  (0) 2023.05.12
백준 18698: The Walking Adam  (0) 2023.05.11

댓글