返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main(){
  5. int x,y,tmp;
  6. re:
  7.     system("cls");
  8. cout<<"請依序輸入兩正整數";
  9. cin>>x>>y;
  10. cout<<"x="<<x<<"y="<<y<<endl;
  11. tmp=x;//x值丟給tmp
  12. x=y;//y值丟給x
  13. y=tmp;//同理
  14. cout<<endl;
  15. cout<<"對調後:"<<endl;
  16. cout<<"x="<<x<<"y="<<y<<endl;


  17. system("pause");
  18. goto re;
  19. return 0;

  20. }
複製代碼

TOP

返回列表