两个数交换的四种方法
作者:互联网
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;//1011 0100 y = x^y;//0111 = 7 x = x^y;//0011 = 3
4,
int a = 3; int b = 4; a = (a + b) - (b = a);
标签:0111,0011,int,交换,0100,方法,1011,四种 来源: https://www.cnblogs.com/zhulei2/p/16545488.html