本帖最後由 許婷芳 於 2020-10-24 20:39 編輯
- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main()
- {
- int x,y,tmp;
- cout<<"請依序輸入兩個正整數: ";
- cin>>x>>y;
- cout<<"對調前: ";
- cout<<"x="<<x<<" y="<<y<<endl<<endl;
-
- tmp=x;
- x=y;
- y=tmp;
-
- cout<<"對調後: ";
- cout<<"x="<<x<<" y="<<y<<endl<<endl;
-
- system("pause");
- return 0;
- }
複製代碼 |