請將第一天完成的if...else 判斷式,使用三元運算子做更改


> 大於
< 小於
== 等於
>= 大於或等於
<= 小於或等於
!= 不等於- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main()
- {
- int age; //變數名稱與要做的事有一定程度的相關
- cout<<"請輸入你的年紀: ";
- cin>>age;
- if(age>=18)
- cout<<"恭喜!可以考駕照了!"<<endl;
- else
- cout<<"未滿18,還得再等一等喔!"<<endl;
- system("pause");
- return 0;
- }
複製代碼本帖隱藏的內容需要回復才可以瀏覽 |