14104 - BMI Calculator   

Description

給定一個名為Body的struct,如下列所示:

Body

  • double height

  • double weight

 

再給定主要執行程式main.c (題號.c)、以及Header檔function.h (題號.h);請試著完成Header檔中未實現的函式:SetHeight()、SetWeight()、ConvertHeight()、GetBMI()

 

Methods:

- void SetHeight(Body* bd, double _height) – 設定身高

- void SetWeight(Body* bd, double _weight) – 設定體重

- double ConvertHeight(Body bd)-將身高(公分cm)轉為身高(公尺m)並回傳

- double GetBMI(Body bd) – 回傳計算後的BMI值

#include "function.h"

void SetHeight(Body *bd, double _height) {


  // TO DO


}

void SetWeight(Body *bd, double _weight) {
 

  // TO DO


}

double ConvertHeight(Body bd) {
 

  // TO DO


}

double GetBMI(Body bd) {
 

  // TO DO


}

 

Hint:

  1. BMI = 體重(公斤kg) / 身高(公尺m)2

 

Note:

  1. GetBMI的參數Body bd裡的height已用ConvertHeight轉成身高(公尺m)

Input

*height *weight

 

Note:

  1. 無需處理輸入

  2. *height單位為公分(cm)

  3. *height, *weight為整數

  4. 0 < *height <= 300

  5. 0 < *weight <= 700

 

 

Output

輸出比須符合以下格式:

BMI: *bmi

 

Note:

  1. 輸出的最後必須要有一個換行符號 ("\n")      

  2. 無需處理輸出

Sample Input  Download

Sample Output  Download

Partial Judge Code

14104.c

Partial Judge Header

14104.h

Tags




Discuss