---
# System prepended metadata

title: 2021/01/31 解題筆記

---


# 2021/01/31 解題筆記
```c=
#include <iostream>

using namespace std;

int main()
{
   int a[10],max_num=0,min_num,sum;

   for(int i=0;i<10;i++){
    cin>>a[i];
   }
   min_num=a[0];

   for (int i=0;i<10;i++){
    if(a[i]>=max_num){
        max_num=a[i];
    }
    if(a[i]<=min_num){
        min_num=a[i];
    }
   }
   cout<<"最大值="<<max_num<<endl;
   cout<<"最小值="<<min_num<<endl;

    return 0;
}
```
## bmi程式
```clike=
#include <iostream>

using namespace std;

int main()
{
    float x,y,z;
    cout<<"請輸入身高(CM)\n";

    cin>>y;
    
    cout<<"請輸入體重(kg)\n";

    cin>>x;

    z=x/((y/100.0)*(y/100.0));

    cout<<"身高="<<y<<"(cm)\n";

    cout<<" \n";

    cout<<"體重="<<x<<"(kg)\n";

    cout<<" \n";

    cout<<"BMI="<<z<<"\n";

    cout<<" \n";

    if(z<18.5){
        cout<<"BMI未達18.5，體重過輕\n"
    }
     if(z>=18.5 && z<24){
        cout<<"BMI高於18.5，未達24，體重正常\n";
    }
     if(z>=24 && z<27){
        cout<<"BMI高於24，未達27，體重過重\n";
    }
    if(z>=27 && z<30){
        cout<<"BMI高於27，未達30，輕度肥胖\n";
    }
    if(z>=30 && z<35){
        cout<<"BMI高於30，未達35，中度肥胖\n";
    }
     if(z>=35){
        cout<<"BMI高於35，重度肥胖\n";
    }


}



```