(转)交换数 不用额外空间
#include <stdio.h> #include <stdlib.h> int main(){ int a=5; int b=8; printf("a=%d,b=%d",a,b); a=a^b; b=a^b; a=a^b; printf("a=%d,b=%d",a,b); }
#include <stdio.h> #include <stdlib.h> int main(){ int a=5; int b=8; printf("a=%d,b=%d",a,b); a=a^b; b=a^b; a=a^b; printf("a=%d,b=%d",a,b); }