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;
}
时间: 2024-10-16 10:48:00