其他分享
首页 > 其他分享> > 【Practical】异或运算

【Practical】异或运算

作者:互联网

#include<iostream>
using namespace std;

int main() 
{
	int a = 3;
	int b = 5;

	cout << "a:" << a << " b:" << b << endl;

	int tmp = a;
	a = b;
	b = tmp;

	cout << "a:" << a << " b:" << b << endl;

	return 0;
}
#include<iostream>
using namespace std;

int main() 
{
	int a = 3;
	int b = 5;

	cout << "a:" << a << " b:" << b << endl;

	a = a ^ b;
	b = a ^ b;
	a = a ^ b;

	cout << "a:" << a << " b:" << b << endl;

	return 0;
}
a = a + b;
b = a - b;
a = a - b;

标签:运算,int,cout,数值,Practical,异或,变量
来源: https://blog.csdn.net/weixin_44246009/article/details/116863342