Interviewer asked: "How to exchange two variables without opening a space." (Preferably, the resources are valuable in the embedded system).
The answer is that the use bit is as follows:
Void
SWAP
int
a,
int
b)
{A = a ^ b; b = b ^ a; a = a ^ b;}
The examiner said that if A, b is full of 32 digits, the bit operation will overflow.
I don't know if it is correct.
Void
SWAP
int
a,
int
b)
{A = a b; b = a-b; a = a-b;}