做题了,做题了,看谁能搞清楚# JobHunting - 待字闺中
d*n
1 楼
swap a and b using XOR (no the third variable). The following function is
correct? Explain
swap(int *a, int *b)
{
*a ^= *b ^= *a ^= *b;
}
I found that if I write it as follows, it's correct
*a ^= *b;
*b ^= *a;
*a ^= *b;
but *a ^= *b ^= *a ^= *b is wrong but why? explain in detail
correct? Explain
swap(int *a, int *b)
{
*a ^= *b ^= *a ^= *b;
}
I found that if I write it as follows, it's correct
*a ^= *b;
*b ^= *a;
*a ^= *b;
but *a ^= *b ^= *a ^= *b is wrong but why? explain in detail