iOS-InterviewQuestion-collection icon indicating copy to clipboard operation
iOS-InterviewQuestion-collection copied to clipboard

[计算题][第二题]交换两个变量 不太对

Open sunyazhou13 opened this issue 3 years ago • 1 comments

int a = 5;
int b = 10;

正解应该是


a  ^= b;
b ^= a;
a ^=b;

考察的是按位异或操作的原理

sunyazhou13 avatar Dec 22 '21 01:12 sunyazhou13

这个题的出处是大学时候 C程序设计(第四版) 谭浩强 课后习题 作业

sunyazhou13 avatar Dec 22 '21 01:12 sunyazhou13