返回列表 發帖

if...else if...else 判斷式

本帖最後由 tonyh 於 2018-7-12 10:24 編輯

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.    int a, b;
  7.    cout<<"請輸入a: ";
  8.    cin>>a;
  9.    cout<<"請輸入b: ";
  10.    cin>>b;
  11.    //cout<<"a:"<<a<<endl;
  12.    //cout<<"b:"<<b<<endl;
  13.    if(a>b)
  14.    {
  15.        cout<<"a大於b"<<endl;
  16.    }else if(a<b)
  17.    {
  18.        cout<<"a小於b"<<endl;   
  19.    }else
  20.    {
  21.        cout<<"a等於b"<<endl;  
  22.    }
  23.    system("pause");   
  24.    return 0;
  25. }
複製代碼

返回列表