两个数交换的四种方法
1,
int x = 7;
int y = 3;
int t;
t=x;
x=y;
y=t;
2,
int x = 7;
int y = 3;
x = x + y;
y = x - y;
x = x - y;
3,
int x = 7; //0111
int y = 3; //0011
x = x^y;//0100
y = x^y;//0111 = 7
x = x^y;//0011 = 3
4,
int a = 3; int b = 4; a = (a + b) - (b = a);
心有所想,必有回响