返回列表 發帖
  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>=45)
  11.     {
  12.         cout<<"你是火星人嗎?"<<endl;
  13.         goto re;
  14.     }else if(height<0.6)
  15.     {
  16.         cout<<"爛"<<endl;  
  17.         goto re;
  18.     }
  19.     re2:
  20.     cout<<"請輸入您的體重(公斤):";
  21.     cin>>weight;
  22.     if(weight>=350)
  23.     {
  24.         cout<<"動物"<<endl;
  25.         goto re2;  
  26.     }else if(weight<=15)
  27.     {
  28.         cout<<"胖虎"<<endl;
  29.         goto re2;  
  30.     }
  31.     BMI=weight/(height*height);
  32.     cout<<"您的BMI值為:"<<BMI<<endl<<"您的BMI分級為:";
  33.     if(BMI<19.7)
  34.     {
  35.         cout<<"體重過輕!!"<<endl;
  36.     }else if(BMI>=19.7&&BMI<24)
  37.     {
  38.         cout<<"正常!"<<endl;  
  39.     }else if(BMI>=24&&BMI<27)
  40.     {
  41.         cout<<"太重"<<endl;
  42.     }else if(BMI>=17&&BMI<20)
  43.     {
  44.         cout<<"跟女朋友ㄘㄟˋ !"<<endl;   
  45.     }else if(BMI>=20&&BMI<25)
  46.     {
  47.         cout<<"處罰 一整年吃菜!"<<endl;
  48.     }else
  49.     {
  50.         cout<<"重度肥胖!送醫院!"<<endl;
  51.     }
  52.     system("pause");
  53.     return 0;
  54. }
複製代碼

TOP

這是我改果的 請看這份
  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>=45)
  11.     {
  12.         cout<<"你是火星人嗎? 請投100塊"<<endl;
  13.         goto re;
  14.     }else if(height<0.6)
  15.     {
  16.         cout<<"爛 請投100塊"<<endl;  
  17.         goto re;
  18.     }
  19.     re2:
  20.     cout<<"請輸入您的體重(公斤):";
  21.     cin>>weight;
  22.     if(weight>=350)
  23.     {
  24.         cout<<"動物 請投100塊"<<endl;
  25.         goto re2;  
  26.     }else if(weight<=15)
  27.     {
  28.         cout<<"胖虎 請投100塊"<<endl;
  29.         goto re2;  
  30.     }
  31.     BMI=weight/(height*height);
  32.     cout<<"您的BMI值為:"<<BMI<<endl<<"您的BMI分級為:";
  33.     if(BMI<19.7)
  34.     {
  35.         cout<<"體重過輕!!請投100塊"<<endl;
  36.     }else if(BMI>=19.7&&BMI<24)
  37.     {
  38.         cout<<"正常!請投100塊"<<endl;  
  39.     }else if(BMI>=24&&BMI<27)
  40.     {
  41.         cout<<"太重 請投100塊"<<endl;
  42.     }else if(BMI>=17&&BMI<20)
  43.     {
  44.         cout<<"跟女朋友ㄘㄟˋ請投100塊 !"<<endl;   
  45.     }else if(BMI>=20&&BMI<25)
  46.     {
  47.         cout<<"處罰 一整年吃菜!請投100塊"<<endl;
  48.     }else
  49.     {
  50.         cout<<"重度肥胖!送醫院!請投100塊"<<endl;
  51.     }
  52.     system("pause");
  53.     return 0;
  54. }
複製代碼

TOP

回復 5# 張文擇


   

TOP

返回列表