返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     float height, weight, BMI;
  7.     re:
  8.     cout << "請輸入您的身高(公尺):";
  9.     cin >> height;
  10.     if(height >= 100)
  11.     {
  12.         cout << "你是巨人嗎?"<<endl;
  13.         goto re;
  14.     }else if(height < 0.3)
  15.     {
  16.         cout << "你是螞蟻?" << endl;  
  17.         goto re;
  18.     }
  19.     re2:
  20.     cout << "請輸入您的體重(公斤):";
  21.     cin >> weight;
  22.     if(weight >= 500)
  23.     {
  24.         cout << "你是豬嗎?" <<endl;
  25.         goto re2;  
  26.     }else if(weight <= 0.1)
  27.     {
  28.         cout << "你是羽毛嗎?" << endl;
  29.         goto re2;  
  30.     }
  31.     BMI = weight / (height * height);
  32.     cout << "您的BMI值為:" << BMI << endl << "您的BMI分級為:";
  33.     if(BMI < 18.5)
  34.     {
  35.         cout << "太輕了!多吃一點!" <<endl;
  36.     }else if(BMI >= 18.5 && BMI < 24)
  37.     {
  38.         cout << "還不錯!繼續吃!" << endl;  
  39.     }else if(BMI >= 24 && BMI < 27)
  40.     {
  41.         cout<<"過重了啦!去減肥!"<<endl;  
  42.     }else if(BMI >= 27 && BMI< 30)
  43.     {
  44.         cout<<"有點胖喔!不愧是豬!"<<endl;   
  45.     }else if(BMI >= 30 && BMI < 35)
  46.     {
  47.         cout<<"有點誇張喔!豬公"<<endl;
  48.     }else
  49.     {
  50.         cout<<"直接死一死算了!反正也沒救了"<<endl;
  51.     }
  52.     system("pause");
  53.     return 0;
  54. }
複製代碼

TOP

返回列表