利用位操作符,不创建临时变量,交换两个数

#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",a,b);
	system("pause");
	return 0;
}

猜你喜欢

转载自blog.csdn.net/weixin_44781107/article/details/89285964