#include <stdio.h>
int main(void)
{
int a = 34;
int b = 78;
printf("a=%d, b=%d\n", a, b);
// exchange two number a and b by bit operation method
a = a ^ b;
b = a ^ b;
a = a ^ b;
printf("after exchange: a=%d, b=%d\n", a, b);
return 0;
}
快速交换2个数的值,位运算
最新推荐文章于 2023-02-23 13:57:43 发布