返回列表 發帖
本帖最後由 蔡季樺 於 2015-10-9 09:12 編輯
  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>=30)
  11.     {
  12.         cout<<"你是科學怪人嗎?"<<endl;
  13.         goto re;
  14.     }else if(height<0.3)
  15.     {
  16.         cout<<"Are you is a 侏儒"<<endl;  
  17.         goto re;
  18.     }
  19.     re2:
  20.     cout<<"請輸入您的體重(公斤):";
  21.     cin>>weight;
  22.     if(weight>=300)
  23.     {
  24.         cout<<"你是ㄅㄨ一豬!!!"<<endl;
  25.         goto re2;  
  26.     }else if(weight<=10)
  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

返回列表