这个问题就用到了异或操作,异或^:如果两个数的对应位相同就是0,不同就是1。
完整代码如下:
#include <stdio.h>
#include <stdlib.h>
int main()
{
int a = 10; int b = 20;
a = a^b;
b = a^b;
a = a^b;
printf("%d %d\n", a, b);
system("pause");
return 0;
}
这个问题就用到了异或操作,异或^:如果两个数的对应位相同就是0,不同就是1。
完整代码如下:
#include <stdio.h>
#include <stdlib.h>
int main()
{
int a = 10; int b = 20;
a = a^b;
b = a^b;
a = a^b;
printf("%d %d\n", a, b);
system("pause");
return 0;
}