采用异或的不增加中间值方法中的一个细节 void swap(int *a, int *b) { if (a != b) //只有当swap(&a,&a)时才有效防御,其他情况即使a=b也不需要if来判断也正确不会为0 { a ^= b; b ^= a; a ^= b; } }