6 solutions

  • 0
    @ 2025-6-2 14:41:25

    #include using namespace std; int main(){ double m,h; cin>>m>>h; double BMI=1.0m/(hh); if(BMI<18.5){ cout<<"Underweight"<<endl; }else if(BMI>=18.5&&BMI<24){ cout<<"Normal"<<endl; }else if(BMI>=24){ cout<<BMI<<endl; cout<<"Overweight"<<endl; } return 0; }

    • 0
      @ 2025-6-2 14:41:00

      #include using namespace std; int main(){ double m,h; cin>>m>>h; double BMI=1.0m/(hh); if(BMI<18.5){ cout<<"Underweight"<<endl; }else if(BMI>=18.5&&BMI<24){ cout<<"Normal"<<endl; }else if(BMI>=24){ cout<<BMI<<endl; cout<<"Overweight"<<endl; } return 0; }

      • 0
        @ 2025-4-17 17:40:11
        using namespace std;
        int main()
        {
        	double a,b;
        	cin>>a>>b;
        	a=a/(b*b);
        	if(a<18.5)
        	{
        		cout<<"Underweight";
        	}
        	else if(a>=18.5&&a<24)
        	{
        		cout<<"Normal";
        	}
        	else
        	{
        		cout<<a;
        		cout<<endl;
        		cout<<"Overweight";
        	}
        	
        	return 0;
        }
        
        

        判断就好了,但要用double

        • 0
          @ 2025-2-2 11:50:56
          #include <iostream>
          using namespace std;
          int main(){
              double m,h;
              cin>>m>>h;
              double BMI=1.0*m/(h*h);
              if(BMI<18.5){
                  cout<<"Underweight"<<endl;
              }else if(BMI>=18.5&&BMI<24){
                  cout<<"Normal"<<endl;
              }else if(BMI>=24){
                  cout<<BMI<<endl;
                  cout<<"Overweight"<<endl;
              }
              return 0;
          }
          

          注意,身高不是整数,BMI也不是整数。 剩下的,正常计算就可以了,再来三个比较,就OK了!!! 如有错请指出。

          • 0
            @ 2024-11-13 19:35:32

            代码:

            #include<bits/stdc++.h>
            typedef double ll;
            using namespace std;
            const int N=10010;
            ll h;
            ll m; 
            int main(){
            
            	cin.sync_with_stdio(false);
            	ios::sync_with_stdio(0);
            	cin>>m>>h;
            	ll BMI=m/(h*h);
            	if(BMI<18.5){
            		cout<<"Underweight";
            	} 
            	else if(BMI>=18.5&&BMI<24){
            		cout<<"Normal"; 
            	}
            	else{
            		cout<<BMI<<'\n'; 
            		cout<<"Overweight";
            	}
            
            
            	return 0;
            }
            
            
            • 0
              @ 2024-10-29 17:56:03
              #include <bits/stdc++.h>
              #include <cmath>
              using  namespace std;
              int main() {
                  double a,b,c;
                  cin>>a>>b;
                  c=a/(b*b);
                  if(c<18.5){
                      cout<<"Underweight";
                  }
                  else if(c>=18.5&&c<24){
                      cout<<"Normal";
                  }
                  else if(c>=24){
                      cout<<c<<endl<<"Overweight";
                  }
              	
              	return 0;
              }
              
              • 1

              Information

              ID
              392
              Time
              1000ms
              Memory
              256MiB
              Difficulty
              6
              Tags
              # Submissions
              354
              Accepted
              113
              Uploaded By