Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
sunyazhou13 opened this issue Dec 22, 2021 · 1 comment
Open

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

sunyazhou13 opened this issue Dec 22, 2021 · 1 comment

Comments

@sunyazhou13
Copy link

int a = 5;
int b = 10;

正解应该是

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

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

@sunyazhou13
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant