C++取反交换两个数的值

Posted on 2018-12-19 10:59  #大囚长#  阅读(291)  评论(0编辑  收藏  举报
	int a = 1;
	int b = 2;
	cout << "a: "<< a << endl;
	cout << "b: "<< b << endl;
	a = a ^ b;
	b = a ^ b;
	a = a ^ b;
	cout << "a: " << a << endl;
	cout << "b: " << b << endl;