It is easy to swap two variables by using a temp variable, but question is slightly different.
Method 1:
x = x+y;
y = x-y;
x = x-y;
Method 2:
x ^= y ^= x ^= y
Knowledge point
It is easy to swap two variables by using a temp variable, but question is slightly different.
Method 1:
x = x+y;
y = x-y;
x = x-y;
Method 2:
x ^= y ^= x ^= y