四种可变交流swap方法

1.void swap(int &x, int &y){

           int temp=x;

           x=y;

           y=temp;

  }

2.void swap(int &x, int &y){

           x=x+y;

           y=x-y;

           x=x-y;

  }

3.void swap(int &x, int &y){

           x=x-y;

           y=x+y;

           x=y-x;

  }

4.void swap(int &x, int &y){

           x=x^y;

           y=x^y;

           x=x^y;

  }


原文地址:https://www.cnblogs.com/hrhguanli/p/5027092.html