返回列表 發帖

[練習] if...else ~~(驚嘆號,true,false)

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {

  6.    
  7.     //  5>4 正確的 true 跑上面的結果   3<4 錯誤的 false 跑下面的結果
  8.     if(!true) // 加了一個驚嘆號 變成反向結果
  9.     {
  10.         cout<<"true"<<endl;
  11.     }else
  12.     {
  13.         cout<<"false"<<endl;
  14.     }
  15.     cout<<"============================="<<endl;
  16.    
  17.     if(120 != 120 )   // != 不等於   120 != 120   ==等於  120 ==120
  18.     {                          
  19.         cout<<"血壓正常~"<<endl;
  20.     }else
  21.     {
  22.         cout<<"血壓異常!!!"<<endl;         
  23.     }

  24.    
  25.     system("pause");
  26.     return 0;
  27. }
複製代碼

返回列表