fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5.  
  6. string name;
  7. double height, weight;
  8. cin >> name >> height >> weight;
  9.  
  10. double bmi = weight / height / height;
  11.  
  12. cout << name << " (" << bmi << ")" << endl;
  13.  
  14. if (bmi < 18.5) {
  15. cout << "體重過輕" << endl;
  16. } else if (18.5 <= bmi && bmi < 24) {
  17. cout << "體重適中" << endl;
  18. } else {
  19. cout << "體重過重" << endl;
  20. }
  21.  
  22. return 0;
  23. }
Success #stdin #stdout 0s 5276KB
stdin
Arthur 1.73 72
stdout
Arthur (24.0569)
體重過重