  
|
[作業] 判斷a,b(2數比大小)
本帖最後由 鄭繼威 於 2022-12-16 20:08 編輯



完成一個可以判斷a,b大小等於的程式- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main(){
- cout<<"---判斷a,b---"<<endl;
- int a;
- cout<<"請輸入a:";
- cin>>a;
-
- int b;
- cout<<"請輸入b:";
- cin>>b;
-
- if (a > b){
- cout<<a<<">"<<b;
- }
- else if(a < b){
- cout<<a<<"<"<<b;
- }
- else if(a==b){
- cout<<a<<"="<<b;
- }
- else{
- cout<<"其他例外";
- }
- cout<<endl;
- system("pause");
- return 0;
- }
複製代碼 |
|