交换两数的另类实现
程序代码:
#include <stdio.h> #include <stdlib.h> int main(void){ int a = 1; int b = 2; //a= 00000001 //b= 00000010 //(a^=b)=00000011 //(b^=a)=00000001 //(a^=b)=00000010 a ^= b; b ^= a; a ^= b; printf("a=%d b=%d\n", a,b); system("PAUSE"); return 0; }