- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main()
- {
- re:
- float h_cm,w;
- cout<<" h(cm)";
- cin>>h_cm;
- float h_m = h_cm/100;
- cout<<" w(kg)";
- cin>>w;
- float bmi=w/(h_m*h_m);
- if(bmi>=35)
- {
- cout<<"重度肥胖"<<endl;
- }
- else if(bmi>=30)
- {
- cout<<"中度肥胖"<<endl;
- }
- else if(bmi>=27)
- {
- cout<<"輕度肥胖"<<endl;
- }
- else if(bmi>=24)
- {
- cout<<"過重"<<endl;
- }
- else if(bmi>=18.5)
- {
- cout<<"正常範圍"<<endl;
- }
- else if(bmi>=0)
- {
- cout<<"體重過輕"<<endl;
- }
- else
- {
- cout<<"error"<<endl;
- }
- cout<<""<<endl;
- goto re;
- system("pause");
- return 0;
- }
複製代碼 |