// 如果a 与 b 都指向同一个地址,如swap(a,a)// ,那么,得到的结果是a=0,所以a != bvoid Swap(int &a, int &b){ if(a != b) { a ^= b; b ^= a; a ^= b; }}//该片段来自于http://www.codesnippet.cn/detail/2212201411365.html
来源: http://www.codesnippet.cn/detail/2212201411365.html