- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main()
- {
- float height, weight, BMI;
- re:
- cout << "請輸入您的身高(公尺):";
- cin >> height;
- if(height >= 100)
- {
- cout << "你是巨人嗎?"<<endl;
- goto re;
- }else if(height < 0.3)
- {
- cout << "你是螞蟻?" << endl;
- goto re;
- }
- re2:
- cout << "請輸入您的體重(公斤):";
- cin >> weight;
- if(weight >= 500)
- {
- cout << "你是豬嗎?" <<endl;
- goto re2;
- }else if(weight <= 0.1)
- {
- cout << "你是羽毛嗎?" << endl;
- goto re2;
- }
- BMI = weight / (height * height);
- cout << "您的BMI值為:" << BMI << endl << "您的BMI分級為:";
- if(BMI < 18.5)
- {
- cout << "太輕了!多吃一點!" <<endl;
- }else if(BMI >= 18.5 && BMI < 24)
- {
- cout << "還不錯!繼續吃!" << endl;
- }else if(BMI >= 24 && BMI < 27)
- {
- cout<<"過重了啦!去減肥!"<<endl;
- }else if(BMI >= 27 && BMI< 30)
- {
- cout<<"有點胖喔!不愧是豬!"<<endl;
- }else if(BMI >= 30 && BMI < 35)
- {
- cout<<"有點誇張喔!豬公"<<endl;
- }else
- {
- cout<<"直接死一死算了!反正也沒救了"<<endl;
- }
- system("pause");
- return 0;
- }
複製代碼 |