返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.      int x=10, y=5, tmp;
  7.      cout<<"[對調前]"<<endl;
  8.      cout<<"x="<<x<<endl;
  9.      cout<<"y="<<y<<endl;
  10.      cout<<"變數x的位址: "<<&x<<endl;
  11.      cout<<"變數y的位址: "<<&y<<endl<<endl;
  12.      tmp=x;
  13.      x=y;
  14.      y=tmp;
  15.      cout<<"[對調後]"<<endl;
  16.      cout<<"x="<<x<<endl;
  17.      cout<<"y="<<y<<endl;
  18.      cout<<"變數x的位址: "<<&x<<endl;
  19.      cout<<"變數y的位址: "<<&y<<endl<<endl;
  20.      system("pause");
  21.      return 0;
  22. }
複製代碼

TOP

返回列表