C语言实现两个数交换的最优方案
#include <stdio.h>
void swap(int *x, int *y)
{
int temp = (*x) ^ (*y);
*y = temp ^ (*y);
*x = temp ^ (*x);
}
void main()
{
int a = 33;
int b = 66;
int *pa = &a;
int *pb = &b;
swap(pa, pb);
printf("a= %d ,b = %d \n", a, b);
}

#include <stdio.h>
void main()
{
int a = 33;
int b = 66;
a = a ^ b ^ a;
b = a ^ b ^ b;
printf("a= %d ,b = %d \n", a, b);
}
#include <stdio.h>
void swap(int *x, int *y)
{
int temp = *x;
*x = *y;
*y = temp;
}
void main()
{
int a = 33;
int b = 66;
swap(&a, &b);
printf("a= %d ,b = %d \n", a, b);
}