楼主先要理解异或操作符(^):1^0 = 1, 0^1 = 1, 0^0 = 0, 1^1 = 0 。
int变量在内存中是用32位二进制补码表示的,n = 3的二进制补码是(0...0)11, m = 8的二进制补码是(0...0)1000。
n = n ^ m; // n = (0...0)1011, m = (0...0)1000
m = n ^ m; // m = (0...0)11, n = (0...0)1011,m = 3
n = n ^ m; // n = (0...0)1000, n = 8 |