# C++(2) ## 比大小-1 ![](https://i.imgur.com/iL03AY3.png) ```cpp= #include<iostream> using namespace std; int main() { //123456 int a,b; cin>>a>>b; if (a>b) { cout<<"a>b"<<endl; } else if (a==b) { cout<<"a=b"<<endl; } else { cout<<"a<b"<<endl; } return 0; } ``` ## 比大小-2 ```cpp= #include<iostream> using namespace std; int main() { int a,b; cin>>a>>b; if (a>b) { cout<<a<<">"<<b<<endl; } else if (a==b) { cout<<a<<"="<<b<<endl; } else { cout<<a<<"<"<<b<<endl; } return 0; } ``` ## 成績 ![](https://i.imgur.com/NbUcPCj.png) ```cpp= #include <iostream> using namespace std; int main () { int score; cout<<"請輸入一個成績?"; cin>>score; if (score>=80){ cout<<"非常好"<<endl; } else if (score>=60){ cout<<"不錯喔"<<endl; } else {cout<<"要加油"<<endl;} } ``` ## BMI ![](https://i.imgur.com/QAv8Rdr.png) ```cpp= #include <iostream> using namespace std; int main () { double weight,height,BMI; cout<<"請輸入體重(kg)?"; cin>>weight; cout<<"請輸入身高(cm)?"; cin>>height; height=height/100; BMI=weight/(height*height); cout<<"BMI為"<<BMI<<endl; if (BMI<18) {cout<<"體重過輕"<<endl; } else if(BMI<24) {cout<<"體重正常"<<endl; } else if (BMI<27) {cout<<"體重過重"<<endl; } else {cout<<"體重肥胖"<<endl; } } ```