void swap(int *x,int *y);
//传址
int main(){
int x,y;
x=1;y=2;
std::cout << " x=" << x << " y=" << y << "\n";
swap(&x,&y);//传址
std::cout << "after swap: x=" << x << " y=" << y << "\n";
return 0;
}
void swap(int *x,int *y){
*x ^= *y;
*y ^= *x;
*x ^= *y;
}

#include <iostream>
void swap(int &x,int &y);
int main(){
int x,y;
x=1;y=2;
std::cout << " x=" << x << " y=" << y << "\n";
swap(x,y);
std::cout << "after swap: x=" << x << " y=" << y << "\n";
return 0;
}
void swap(int &x,int &y){
x ^= y;
y ^= x;
x ^= y;
}