返回列表 發帖
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
    string x;
    int y,z;
    re:
        cout<<"***歡迎使用小米的BMI計算機***"<<endl;
        cout<<"請輸入你的大名";
        cin>>x;
        cout<<endl;
        cout<<"請輸入你的身高(公尺)";
        cin>>y;
        cout<<endl;
        cout<<"請輸入你的體重(公斤)";
        cin>>z;
        cout<<endl;
        float b;
        b=0.01*y;
        cout<<"親愛的"<<x<<",您的BMI值為"<<z/b/b<<endl;
        float x;
        a = z/b/b;
        if(a<18.5 && a>0)
            cout<<"體重過輕!!你需要多吃點喔!"<<endl;
        else if(a>=18.5 && a<24)
            cout<<"正常範圍!!繼續保持!"<<endl;
        else if(a>=24 && a<27)
            cout<<"過重!!唔..該減肥了!"<<endl;
        else if(a>=27 && a<30)
            cout<<"輕度肥胖!!太胖了!這樣會交不到男(女)朋友!"<<endl;
        else if(a>=30 && a<35)
            cout<<"中度肥胖!!去操場跑個十圈再回來!"<<endl;
        else if (a>=35)
            cout<<"重度肥胖!!你需要立即注意你的飲食,因為你的生命正受到嚴重威脅!"<<endl;
        else
            cout<<"不要再玩了啦! 你是怪物嗎? 再胡鬧小心我扁你!"<<endl;


        goto re;
        system("pause");
        return 0;

}

TOP

返回列表